a11y(bloc-repetable): ETQ usager qui navigue au clavier, lorsque je supprime une repetition, le focus revient soit sur le premier champ de la derniere repetition, soit sur le bouton ajouter une repetition [si il y a pas de repetition presente]
This commit is contained in:
parent
8b6a7689fa
commit
d161a624c5
3 changed files with 9 additions and 3 deletions
|
@ -3,5 +3,5 @@
|
|||
= render EditableChamp::RepetitionRowComponent.new(form: @form, champ: @champ, row: champs, seen_at: @seen_at)
|
||||
|
||||
.actions{ 'data-turbo': 'true' }
|
||||
= button_tag(name: "action", formaction: champs_repetition_path(@champ.id), class: "fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line fr-mb-3w", title: t(".add_title", libelle: @champ.libelle), form: EditableChamp::AddFormRepetitionRowComponent.form_id) do
|
||||
= button_tag(name: "action", formaction: champs_repetition_path(@champ.id), class: "fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line fr-mb-3w", title: t(".add_title", libelle: @champ.libelle), form: EditableChamp::AddFormRepetitionRowComponent.form_id, id: dom_id(@champ, :create_repetition)) do
|
||||
= t(".add", libelle: @champ.libelle)
|
||||
|
|
|
@ -7,8 +7,9 @@ class Champs::RepetitionController < ApplicationController
|
|||
end
|
||||
|
||||
def remove
|
||||
champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
|
||||
champ.champs.where(row_id: params[:row_id]).destroy_all
|
||||
@champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
|
||||
@champ.champs.where(row_id: params[:row_id]).destroy_all
|
||||
@champ.reload
|
||||
@row_id = params[:row_id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
= turbo_stream.remove "safe-row-selector-#{@row_id}"
|
||||
|
||||
- if @champ.rows.size > 0 && @champ.rows.last&.first&.present?
|
||||
= turbo_stream.focus @champ.rows.last&.first.focusable_input_id
|
||||
- else
|
||||
= turbo_stream.focus dom_id(@champ, :create_repetition)
|
||||
|
|
Loading…
Reference in a new issue