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();