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) { private logError(error: ResponseError) {
if (error && error.message) { if (error && error.message) {
error.message = `[Autosave] ${error.message}`;
console.error(error); console.error(error);
this.globalDispatch('sentry:capture-exception', error); this.globalDispatch('sentry:capture-exception', error);
} }

View file

@ -1,5 +1,5 @@
= fields_for @champ.input_name, @champ do |form| = 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? - if @champ.piece_justificative_file.attached?
- attachment = @champ.piece_justificative_file.attachment - 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 it 'renders the attachment template as Javascript' do
subject subject
expect(response.status).to eq(200) 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 end
it 'updates dossier.last_champ_updated_at' do it 'updates dossier.last_champ_updated_at' do