From 912e8af9905c3e8688e25f6b014fd2a482540c2d Mon Sep 17 00:00:00 2001 From: tykayn <15d65f2f-0b14-4f70-bf34-e130180ed62b@users.tedomum.net> Date: Mon, 8 Nov 2021 11:20:07 +0100 Subject: [PATCH] autofocus on first field of creation Signed-off-by: tykayn <15d65f2f-0b14-4f70-bf34-e130180ed62b@users.tedomum.net> --- .../form/steps/step-one/step-one.component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/features/administration/form/steps/step-one/step-one.component.ts b/src/app/features/administration/form/steps/step-one/step-one.component.ts index f013b61b..0107efb2 100644 --- a/src/app/features/administration/form/steps/step-one/step-one.component.ts +++ b/src/app/features/administration/form/steps/step-one/step-one.component.ts @@ -1,6 +1,7 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { PollService } from '../../../../../core/services/poll.service'; +import { DOCUMENT } from '@angular/common'; @Component({ selector: 'app-step-one', @@ -8,12 +9,18 @@ import { PollService } from '../../../../../core/services/poll.service'; styleUrls: ['./step-one.component.scss'], }) export class StepOneComponent implements OnInit { - constructor(public pollService: PollService) {} + constructor(public pollService: PollService, @Inject(DOCUMENT) private document: any) {} @Input() step_max: any; @Input() form: FormGroup; - ngOnInit(): void {} + ngOnInit(): void { + const selector = '#title'; + const firstField = this.document.querySelector(selector); + if (firstField) { + firstField.focus(); + } + } }