From cf93f5637c691d489aeb1e5880921c1cf5fe9f34 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Wed, 16 Feb 2022 11:57:08 +0100 Subject: [PATCH] fix focus modal lang --- .../language-selector/language-selector.component.html | 2 +- .../language-selector/language-selector.component.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/shared/components/selectors/language-selector/language-selector.component.html b/src/app/shared/components/selectors/language-selector/language-selector.component.html index c035d01f..a9c78dd7 100644 --- a/src/app/shared/components/selectors/language-selector/language-selector.component.html +++ b/src/app/shared/components/selectors/language-selector/language-selector.component.html @@ -36,7 +36,7 @@ id="close_dialog{{ idSuffix }}" class="button cancel-button-reject pull-right img-marged-left has-no-border" lang="{{ currentLang }}" - (click)="focusOnCancelButton()" + (click)="closeModalAndFocusOnButtonToOpen()" > {{ 'SENTENCES.Close' | translate }} diff --git a/src/app/shared/components/selectors/language-selector/language-selector.component.ts b/src/app/shared/components/selectors/language-selector/language-selector.component.ts index ef70741f..ba66e7ae 100644 --- a/src/app/shared/components/selectors/language-selector/language-selector.component.ts +++ b/src/app/shared/components/selectors/language-selector/language-selector.component.ts @@ -5,6 +5,7 @@ import { LanguageService } from '../../../../core/services/language.service'; import { StorageService } from '../../../../core/services/storage.service'; import { DOCUMENT } from '@angular/common'; import { PollService } from '../../../../core/services/poll.service'; +import { environment } from '../../../../../environments/environment'; @Component({ selector: 'app-language-selector', @@ -38,16 +39,17 @@ export class LanguageSelectorComponent implements OnInit { this.language_to_apply = '' + this.currentLang; } - setLang(newlang: string = 'fr'): void { + setLang(newlang: string = environment.defaultLanguage): void { this.currentLang = newlang; this.languageService.setLanguage(newlang); this.storageService.language = this.currentLang; this.pollService.updateTitle(); } - focusOnCancelButton() { + closeModalAndFocusOnButtonToOpen() { this.display_lang_dialog = false; - let buttonClose = this.document.querySelector('#display_cancel_popup_button'); + this.cd.detectChanges(); + let buttonClose = this.document.querySelector('#lang_button_popup'); if (buttonClose) { buttonClose.focus(); } @@ -71,6 +73,7 @@ export class LanguageSelectorComponent implements OnInit { applyLangAndClosePopup() { this.setLang(this.language_to_apply); this.display_lang_dialog = false; + this.cd.detectChanges(); let elem = this.document.querySelector('#lang_button_popup'); if (elem) { elem.focus();