Merge pull request #5563 from betagouv/5546-dropdown-accessible

5546 rend accessible les menus déroulants
This commit is contained in:
krichtof 2020-09-15 18:22:04 +02:00 committed by GitHub
commit d755a23dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 38 additions and 36 deletions

View file

@ -192,9 +192,6 @@ $header-mobile-breakpoint: 550px;
background: none; background: none;
} }
&::after {
display: none;
}
} }
.header-menu { .header-menu {

View file

@ -2,16 +2,21 @@ import { delegate } from '@utils';
delegate('click', 'body', (event) => { delegate('click', 'body', (event) => {
if (!event.target.closest('.dropdown')) { if (!event.target.closest('.dropdown')) {
[...document.querySelectorAll('.dropdown')].forEach((element) => [...document.querySelectorAll('.dropdown')].forEach((element) => {
element.classList.remove('open', 'fade-in-down') const button = element.querySelector('.dropdown-button');
); button.setAttribute('aria-expanded', false);
element.classList.remove('open', 'fade-in-down');
});
} }
}); });
delegate('click', '.dropdown-button', (event) => { delegate('click', '.dropdown-button', (event) => {
event.stopPropagation(); event.stopPropagation();
const parent = event.target.closest('.dropdown-button').parentElement; const button = event.target.closest('.dropdown-button');
const parent = button.parentElement;
if (parent.classList.contains('dropdown')) { if (parent.classList.contains('dropdown')) {
parent.classList.toggle('open'); parent.classList.toggle('open');
var buttonExpanded = button.getAttribute('aria-expanded') === 'true';
button.setAttribute('aria-expanded', !buttonExpanded);
} }
}); });

View file

@ -1,7 +1,7 @@
%span.dropdown.print-menu-opener %span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only{ title: 'imprimer', 'aria-label': 'imprimer' } %button.button.dropdown-button.icon-only{ title: 'imprimer', 'aria-label': 'imprimer', 'aria-expanded' => 'false', 'aria-controls' => 'print-menu' }
%span.icon.printer %span.icon.printer
%ul.print-menu.dropdown-content %ul#print-menu.print-menu.dropdown-content
%li %li
= link_to "Tout le dossier", print_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link" = link_to "Tout le dossier", print_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
%li %li
@ -14,9 +14,9 @@
- if PiecesJustificativesService.liste_pieces_justificatives(dossier).present? - if PiecesJustificativesService.liste_pieces_justificatives(dossier).present?
%span.dropdown.print-menu-opener %span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only %button.button.dropdown-button.icon-only{ 'aria-expanded' => 'false', 'aria-controls' => 'print-pj-menu' }
%span.icon.attached %span.icon.attached
%ul.print-menu.dropdown-content %ul#print-pj-menu.print-menu.dropdown-content
%li %li
- if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP - if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP
= link_to "Télécharger toutes les pièces jointes", telecharger_pjs_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link" = link_to "Télécharger toutes les pièces jointes", telecharger_pjs_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"

View file

@ -1,10 +1,10 @@
.dropdown .dropdown
-# Dropdown button title -# Dropdown button title
%button.button.primary.dropdown-button{ class: button_or_label_class(dossier) } %button.button.primary.dropdown-button{ class: button_or_label_class(dossier), 'aria-expanded' => 'false', 'aria-controls' => 'state-menu' }
= dossier_display_state dossier = dossier_display_state dossier
-# Dropdown content -# Dropdown content
.dropdown-content.fade-in-down #state-menu.dropdown-content.fade-in-down
- if dossier.en_construction? - if dossier.en_construction?
-# ------------------------------------------------------ -# ------------------------------------------------------

View file

@ -1,8 +1,8 @@
- if procedure.dossiers.state_not_brouillon.any? - if procedure.dossiers.state_not_brouillon.any?
%span.dropdown %span.dropdown
%button.button.dropdown-button %button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'download-menu' }
Télécharger tous les dossiers Télécharger tous les dossiers
.dropdown-content.fade-in-down{ style: 'width: 330px' } #download-menu.dropdown-content.fade-in-down{ style: 'width: 330px' }
%ul.dropdown-items %ul.dropdown-items
- [[xlsx_export, :xlsx], [ods_export, :ods], [csv_export, :csv]].each do |(export, format)| - [[xlsx_export, :xlsx], [ods_export, :ods], [csv_export, :csv]].each do |(export, format)|
%li %li

View file

@ -78,9 +78,9 @@
- if @dossiers.present? || @current_filters.count > 0 - if @dossiers.present? || @current_filters.count > 0
= paginate @dossiers = paginate @dossiers
%span.dropdown %span.dropdown
%button.button.dropdown-button %button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'filter-menu' }
Filtrer Filtrer
.dropdown-content.left-aligned.fade-in-down #filter-menu.dropdown-content.left-aligned.fade-in-down
= form_tag add_filter_instructeur_procedure_path(@procedure), method: :post, class: 'dropdown-form large' do = form_tag add_filter_instructeur_procedure_path(@procedure), method: :post, class: 'dropdown-form large' do
= label_tag :field, "Colonne" = label_tag :field, "Colonne"
= select_tag :field, options_for_select(@available_fields_to_filters) = select_tag :field, options_for_select(@available_fields_to_filters)
@ -118,9 +118,9 @@
%th.action-col.follow-col %th.action-col.follow-col
%span.dropdown %span.dropdown
%button.button.dropdown-button %button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'custom-menu' }
Personnaliser Personnaliser
.dropdown-content.fade-in-down #custom-menu.dropdown-content.fade-in-down
= form_tag update_displayed_fields_instructeur_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do = form_tag update_displayed_fields_instructeur_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do
= select_tag :values, = select_tag :values,
options_for_select(@procedure_presentation.fields_for_select, options_for_select(@procedure_presentation.fields_for_select,

View file

@ -1,5 +1,5 @@
.dropdown.invite-user-action .dropdown.invite-user-action
%button.button.dropdown-button %button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'invite-content' }
%span.icon.person %span.icon.person
- if dossier.invites.count > 0 - if dossier.invites.count > 0
Voir les personnes invitées Voir les personnes invitées
@ -10,5 +10,5 @@
- else - else
Inviter une personne à modifier ce dossier Inviter une personne à modifier ce dossier
.dropdown-content.fade-in-down #invite-content.dropdown-content.fade-in-down
= render partial: "invites/form", locals: { dossier: dossier } = render partial: "invites/form", locals: { dossier: dossier }

View file

@ -1,8 +1,8 @@
.dropdown.header-menu-opener .dropdown.header-menu-opener
%button.button.dropdown-button.header-menu-button{ title: "Mon compte" } %button.button.dropdown-button.icon-only.header-menu-button{ title: "Mon compte", 'aria-expanded' => 'false', 'aria-controls' => 'mon_compte_menu' }
.hidden Mon compte .hidden Mon compte
= image_tag "icons/account-circle.svg", alt: '' = image_tag "icons/account-circle.svg", alt: 'Mon compte'
%ul.header-menu.dropdown-content %ul.header-menu.dropdown-content#mon_compte_menu
%li %li
.menu-item{ title: current_email } .menu-item{ title: current_email }
= current_email = current_email

View file

@ -33,9 +33,9 @@
%span.icon.edit %span.icon.edit
Modifier Modifier
.dropdown .dropdown
.button.dropdown-button.procedures-actions-btn .button.dropdown-button.procedures-actions-btn{ 'aria-expanded' => 'false', 'aria-controls' => 'actions-menu' }
Actions Actions
.dropdown-content.fade-in-down #actions-menu.dropdown-content.fade-in-down
%ul.dropdown-items.pl-0 %ul.dropdown-items.pl-0
- if !procedure.close? - if !procedure.close?
%li %li

View file

@ -1,6 +1,6 @@
.dropdown.help-dropdown .dropdown.help-dropdown
%button.button.primary.dropdown-button Aide %button.button.primary.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'help-menu' } Aide
.dropdown-content.fade-in-down #help-menu.dropdown-content.fade-in-down
%ul.dropdown-items %ul.dropdown-items
- title = dossier.brouillon? ? "Besoin daide pour remplir votre dossier ?" : "Une question sur votre dossier ?" - title = dossier.brouillon? ? "Besoin daide pour remplir votre dossier ?" : "Une question sur votre dossier ?"

View file

@ -1,6 +1,6 @@
.dropdown.help-dropdown .dropdown.help-dropdown
%button.button.primary.dropdown-button Aide %button.button.primary.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'help-menu' } Aide
.dropdown-content.fade-in-down #help-menu.dropdown-content.fade-in-down
%ul.dropdown-items %ul.dropdown-items
= render partial: 'shared/help/dropdown_items/faq_item' = render partial: 'shared/help/dropdown_items/faq_item'
= render partial: 'shared/help/dropdown_items/email_item' = render partial: 'shared/help/dropdown_items/email_item'

View file

@ -1,6 +1,6 @@
.dropdown.help-dropdown .dropdown.help-dropdown
%button.button.primary.dropdown-button Aide %button.button.primary.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'help-menu' } Aide
.dropdown-content.fade-in-down #help-menu.dropdown-content.fade-in-down
%ul.dropdown-items %ul.dropdown-items
- if procedure.service.present? - if procedure.service.present?
= render partial: 'shared/help/dropdown_items/service_item', = render partial: 'shared/help/dropdown_items/service_item',

View file

@ -5,9 +5,9 @@
- if has_actions - if has_actions
.dropdown.user-dossier-actions .dropdown.user-dossier-actions
%button.button.dropdown-button %button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'actions-menu' }
Actions Actions
.dropdown-content.fade-in-down #actions-menu.dropdown-content.fade-in-down
%ul.dropdown-items %ul.dropdown-items
- if !dossier.read_only? - if !dossier.read_only?
- if dossier.brouillon? - if dossier.brouillon?

View file

@ -16,9 +16,9 @@
- if dossier.can_be_updated_by_user? && !current_page?(modifier_dossier_path(dossier)) - if dossier.can_be_updated_by_user? && !current_page?(modifier_dossier_path(dossier))
= link_to "Modifier mon dossier", modifier_dossier_path(dossier), class: 'button accepted edit-form', 'title'=> "Vous pouvez modifier votre dossier tant qu'il n'est passé en instruction" = link_to "Modifier mon dossier", modifier_dossier_path(dossier), class: 'button accepted edit-form', 'title'=> "Vous pouvez modifier votre dossier tant qu'il n'est passé en instruction"
%span.dropdown.print-menu-opener %span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only{ title: 'imprimer', 'aria-label': 'imprimer' } %button.button.dropdown-button.icon-only{ title: 'imprimer', 'aria-label': 'imprimer', 'aria-expanded' => 'false', 'aria-controls' => 'print-menu' }
%span.icon.printer %span.icon.printer
%ul.print-menu.dropdown-content %ul#print-menu.print-menu.dropdown-content
%li %li
= link_to "Tout le dossier", dossier_path(dossier, format: :pdf), target: "_blank", rel: "noopener", class: "menu-item menu-link" = link_to "Tout le dossier", dossier_path(dossier, format: :pdf), target: "_blank", rel: "noopener", class: "menu-item menu-link"