fix focus modal lang

This commit is contained in:
Tykayn 2022-02-16 11:57:08 +01:00 committed by tykayn
parent 80736d111f
commit cf93f5637c
2 changed files with 7 additions and 4 deletions

View File

@ -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 }}
<img class="icon" src="assets/icons/x_blue.svg" />

View File

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