lang selector aria and ids

This commit is contained in:
Tykayn 2022-02-15 12:32:27 +01:00 committed by tykayn
parent 00a2dd7e1d
commit 5d25754c16
4 changed files with 57 additions and 36 deletions

View File

@ -82,11 +82,7 @@
> >
<ng-template pTemplate="titlebar"> <ng-template pTemplate="titlebar">
<div class="columns"> <div class="columns">
<div class="column"> <div class="column"></div>
<h1 class="title">
{{ 'hours.modal.title' | translate }}
</h1>
</div>
<div class="column is-narrow"> <div class="column is-narrow">
<button <button
id="close_dialog" id="close_dialog"
@ -97,7 +93,9 @@
</button> </button>
</div> </div>
</div> </div>
<h1 class="title">
{{ 'hours.modal.title' | translate }}
</h1>
<section class="same-time-slices"> <section class="same-time-slices">
<section class="same-time-slices"> <section class="same-time-slices">
<section class="proposals" *ngIf="environment.creation_display_proposals_time_slices"> <section class="proposals" *ngIf="environment.creation_display_proposals_time_slices">

View File

@ -3,6 +3,7 @@
id="lang_button_popup{{ idSuffix }}" id="lang_button_popup{{ idSuffix }}"
class="lang-button" class="lang-button"
(click)="openDialogLang()" (click)="openDialogLang()"
[attr.aria-controls]="'lang_selector_modale'"
[attr.aria-label]="'LANGUAGES.' + currentLang.toUpperCase() | translate" [attr.aria-label]="'LANGUAGES.' + currentLang.toUpperCase() | translate"
> >
<i class="fa fa-language"></i> <i class="fa fa-language"></i>
@ -22,22 +23,31 @@
[draggable]="false" [draggable]="false"
[showHeader]="false" [showHeader]="false"
[resizable]="true" [resizable]="true"
[attr.aria-labelledby]="'popup.languages.title' | translate"
role="dialog"
id="lang_selector_modale"
> >
<ng-template pTemplate="titlebar"> <ng-template pTemplate="titlebar">
<div class="columns">
<div class="column">
<div class="top"> <div class="top">
<button <button
id="close_dialog{{ idSuffix }}" id="close_dialog{{ idSuffix }}"
class="button cancel-button-reject pull-right img-marged-left" class="button cancel-button-reject pull-right img-marged-left"
lang="{{ currentLang }}"
(click)="focusOnCancelButton()" (click)="focusOnCancelButton()"
> >
{{ 'SENTENCES.Close' | translate }} {{ 'SENTENCES.Close' | translate }}
<img class="icon" src="assets/icons/x_blue.svg" /> <img class="icon" src="assets/icons/x_blue.svg" />
</button> </button>
</div> </div>
<h2 class="title is-2 has-text-left"> </div>
</div>
<h1 class="title is-2 has-text-left" id="lang_selector_modale_title">
{{ 'popup.languages.title' | translate }} {{ 'popup.languages.title' | translate }}
</h2> </h1>
<div class="list-of-langs">
<button <button
class="lang-element button" class="lang-element button"
[ngClass]="{ 'is-primary': language_to_apply === language, 'is-current': language === currentLang }" [ngClass]="{ 'is-primary': language_to_apply === language, 'is-current': language === currentLang }"
@ -49,14 +59,18 @@
{{ language }} - {{ language }} -
{{ 'LANGUAGES.' + language.toUpperCase() | translate }} {{ 'LANGUAGES.' + language.toUpperCase() | translate }}
</button> </button>
</div>
</ng-template> </ng-template>
<ng-template pTemplate="footer"> <ng-template pTemplate="footer">
<button class="button" (click)="applyLangAndClosePopup()"> <div class="buttons-bottom">
<button class="button" (click)="applyLangAndClosePopup()" lang="{{ currentLang }}">
{{ 'SENTENCES.Cancel' | translate }} {{ 'SENTENCES.Cancel' | translate }}
</button> </button>
<button class="button is-primary" (click)="applyLangAndClosePopup()"> <button class="button is-primary" (click)="applyLangAndClosePopup()" lang="{{ currentLang }}">
{{ 'nav.save' | translate }} {{ 'nav.save' | translate }}
</button> </button>
</div>
</ng-template> </ng-template>
</p-dialog> </p-dialog>
</div> </div>

View File

@ -35,7 +35,14 @@
.lang-element { .lang-element {
float: left; float: left;
margin: 0.5em; margin: 0.5em;
min-width: 11em; min-width: 8em;
border: 0;
border-radius: 2rem;
padding: 0.5rem 0.25rem;
&:hover {
background: $d-neutral;
}
} }
.is-current { .is-current {

View File

@ -1,4 +1,4 @@
import { Component, Inject, Input, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, Inject, Input, OnInit } from '@angular/core';
import { LanguageEnum } from '../../../../core/enums/language.enum'; import { LanguageEnum } from '../../../../core/enums/language.enum';
import { LanguageService } from '../../../../core/services/language.service'; import { LanguageService } from '../../../../core/services/language.service';
@ -23,6 +23,7 @@ export class LanguageSelectorComponent implements OnInit {
private languageService: LanguageService, private languageService: LanguageService,
private storageService: StorageService, private storageService: StorageService,
private pollService: PollService, private pollService: PollService,
private cd: ChangeDetectorRef,
@Inject(DOCUMENT) private document: any @Inject(DOCUMENT) private document: any
) {} ) {}
@ -78,7 +79,8 @@ export class LanguageSelectorComponent implements OnInit {
openDialogLang() { openDialogLang() {
this.display_lang_dialog = true; this.display_lang_dialog = true;
let elem = this.document.querySelector('#lang_button_popup'); this.cd.detectChanges();
let elem = this.document.querySelector('#close_dialog');
if (elem) { if (elem) {
elem.focus(); elem.focus();
} }