feat(champ): use new data-turbo-focus-group to manage focus on multiple drop down

This commit is contained in:
Paul Chavard 2023-04-27 09:39:21 +02:00
parent 5343c229a2
commit f9b8dac024
3 changed files with 8 additions and 13 deletions

View file

@ -5,6 +5,7 @@
- b.label(for: @champ.checkbox_id(b.value)) do
- b.check_box({ multiple: true, checked: @champ.selected_options.include?(b.value), aria: { describedby: @champ.describedby_id }, id: @champ.checkbox_id(b.value) }) + b.text
- else
%div{ 'data-turbo-focus-group': true }
- if @champ.selected_options.present?
.fr-mb-2w{ "data-turbo": "true" }
- @champ.selected_options.each do |option|

View file

@ -3,7 +3,6 @@ class Champs::OptionsController < ApplicationController
def remove
@champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
@next_checkbox_id = @champ.next_checkbox_id(params[:option])
@champ.remove_option([params[:option]].compact)
end
end

View file

@ -1,8 +1,3 @@
= fields_for @champ.input_name, @champ do |form|
= turbo_stream.replace @champ.input_group_id do
= render EditableChamp::EditableChampComponent.new champ: @champ, form:
- if @next_checkbox_id.present?
= turbo_stream.focus @next_checkbox_id
- else
= turbo_stream.focus @champ.input_id