diff --git a/app/components/editable_champ/repetition_component/repetition_component.html.haml b/app/components/editable_champ/repetition_component/repetition_component.html.haml index 392986d3c..f0478483d 100644 --- a/app/components/editable_champ/repetition_component/repetition_component.html.haml +++ b/app/components/editable_champ/repetition_component/repetition_component.html.haml @@ -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) diff --git a/app/controllers/champs/repetition_controller.rb b/app/controllers/champs/repetition_controller.rb index 25d15c07b..b13979716 100644 --- a/app/controllers/champs/repetition_controller.rb +++ b/app/controllers/champs/repetition_controller.rb @@ -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 diff --git a/app/views/champs/repetition/remove.turbo_stream.haml b/app/views/champs/repetition/remove.turbo_stream.haml index 3e1a66058..5fb0fe0be 100644 --- a/app/views/champs/repetition/remove.turbo_stream.haml +++ b/app/views/champs/repetition/remove.turbo_stream.haml @@ -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)