fix(autosave): morph instead of replace to preserve controller instances

This commit is contained in:
Paul Chavard 2022-07-26 11:03:31 +02:00
parent 01c0b4350b
commit 4276745338
2 changed files with 2 additions and 2 deletions

View file

@ -1,5 +1,5 @@
= fields_for @champ.input_name, @champ do |form|
= turbo_stream.replace @champ.input_group_id, partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: @champ, form: form }
= turbo_stream.morph @champ.input_group_id, partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: @champ, form: form }
- if @champ.piece_justificative_file.attached?
- attachment = @champ.piece_justificative_file.attachment

View file

@ -29,7 +29,7 @@ describe Champs::PieceJustificativeController, type: :controller do
it 'renders the attachment template as Javascript' do
subject
expect(response.status).to eq(200)
expect(response.body).to include("action=\"replace\" target=\"#{champ.input_group_id}\"")
expect(response.body).to include(""action":"morph","target":"#{champ.input_group_id}"")
end
it 'updates dossier.last_champ_updated_at' do