From c3fd555e6c8c3cf1e26f8f65be14c2fd6e2d22d0 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 28 Dec 2022 16:47:52 +0100 Subject: [PATCH] amelioration(a11y.invites): focus sur la liste des invitations lorsqu'on ajoute un invite a un dossier --- app/views/invites/_dropdown.html.haml | 2 +- app/views/invites/_form.html.haml | 16 +++++++++------- app/views/invites/create.turbo_stream.haml | 4 ++-- app/views/invites/destroy.turbo_stream.haml | 6 +++--- app/views/shared/dossiers/_header.html.haml | 2 +- app/views/users/dossiers/show/_header.html.haml | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/views/invites/_dropdown.html.haml b/app/views/invites/_dropdown.html.haml index dad812910..63c7f812b 100644 --- a/app/views/invites/_dropdown.html.haml +++ b/app/views/invites/_dropdown.html.haml @@ -11,4 +11,4 @@ - else = t('views.invites.dropdown.invite_to_edit') - menu.with_form do - = render partial: "invites/form", locals: { dossier: dossier, invites: invites } + = render partial: "invites/form", locals: { dossier: dossier, invites: invites, morphing: morphing } diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index 49dffeb35..f79ccff83 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -1,12 +1,14 @@ #invites-form - if invites.present? - %h4= t('views.invites.form.invite_to_participate') - %ul - - invites.each do |invite| - %li - = invite.email - %small{ 'data-turbo': 'true' } - = link_to t('views.invites.form.withdraw_permission'), invite_path(invite), data: { turbo_method: :delete, turbo_confirm: t('views.invites.form.want_to_withdraw_permission') } + #invite-list{ morphing ? { tabindex: "-1" } : {} } + %h4= t('views.invites.form.invite_to_participate') + %ul + - invites.each do |invite| + %li + = invite.email + %small{ 'data-turbo': 'true' } + = link_to t('views.invites.form.withdraw_permission'), invite_path(invite), data: { turbo_method: :delete, turbo_confirm: t('views.invites.form.want_to_withdraw_permission') } + %p= t('views.invites.form.edit_dossier') - if dossier.brouillon? %p= t('views.invites.form.submit_dossier_yourself') diff --git a/app/views/invites/create.turbo_stream.haml b/app/views/invites/create.turbo_stream.haml index d31956ae4..6832db349 100644 --- a/app/views/invites/create.turbo_stream.haml +++ b/app/views/invites/create.turbo_stream.haml @@ -1,2 +1,2 @@ -= turbo_stream.replace_all '.invite-user-action', partial: 'invites/dropdown', locals: { dossier: @dossier } -= turbo_stream.focus 'invite_email' += turbo_stream.replace_all '.invite-user-action', partial: 'invites/dropdown', locals: { dossier: @dossier, morphing: true } += turbo_stream.focus 'invite-list' diff --git a/app/views/invites/destroy.turbo_stream.haml b/app/views/invites/destroy.turbo_stream.haml index 34f54f0b2..a891215dc 100644 --- a/app/views/invites/destroy.turbo_stream.haml +++ b/app/views/invites/destroy.turbo_stream.haml @@ -1,6 +1,6 @@ - if @dossier.present? - = turbo_stream.replace_all '.invite-user-action', partial: 'invites/dropdown', locals: { dossier: @dossier } + = turbo_stream.replace_all '.invite-user-action', partial: 'invites/dropdown', locals: { dossier: @dossier, morphing: true } - if @dossier.invites.empty? - = turbo_stream.focus 'invite_email' + = turbo_stream.focus 'invite-list' - else - = turbo_stream.focus_all '#invites-form ul a:first-child' + = turbo_stream.focus 'invite_email' diff --git a/app/views/shared/dossiers/_header.html.haml b/app/views/shared/dossiers/_header.html.haml index bf3fa62e8..95e985c6c 100644 --- a/app/views/shared/dossiers/_header.html.haml +++ b/app/views/shared/dossiers/_header.html.haml @@ -12,7 +12,7 @@ = render(partial: 'users/dossiers/procedure_removed_banner', locals: { dossier: dossier }) - elsif current_user.owns?(dossier) .header-actions - = render partial: 'invites/dropdown', locals: { dossier: dossier } + = render partial: 'invites/dropdown', locals: { dossier: dossier, morphing: false } - unless dossier.read_only? = render partial: 'users/dossiers/identity_dropdown', locals: { dossier: dossier } diff --git a/app/views/users/dossiers/show/_header.html.haml b/app/views/users/dossiers/show/_header.html.haml index 6139f57ba..14179155d 100644 --- a/app/views/users/dossiers/show/_header.html.haml +++ b/app/views/users/dossiers/show/_header.html.haml @@ -16,7 +16,7 @@ = render(partial: 'users/dossiers/procedure_removed_banner', locals: { dossier: dossier }) - elsif current_user.owns?(dossier) .header-actions - = render partial: 'invites/dropdown', locals: { dossier: dossier } + = render partial: 'invites/dropdown', locals: { dossier: dossier, morphing: false } - if dossier.can_be_updated_by_user? && !current_page?(modifier_dossier_path(dossier)) = link_to t('views.users.dossiers.show.header.edit_dossier'), modifier_dossier_path(dossier), class: 'fr-btn fr-btn-sm', title: { label: t('views.users.dossiers.show.header.edit_dossier_title') }