Merge pull request #7611 from tchak/fix-autosave

fix(autosave): morph instead of replace to preserve controller instances
This commit is contained in:
Paul Chavard 2022-07-26 11:53:50 +02:00 committed by GitHub
commit 14f67306fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 3 deletions

View file

@ -85,7 +85,6 @@ export class AutosaveStatusController extends ApplicationController {
private logError(error: ResponseError) {
if (error && error.message) {
error.message = `[Autosave] ${error.message}`;
console.error(error);
this.globalDispatch('sentry:capture-exception', error);
}

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