Skip to content

Commit

Permalink
Fix, only auto-save inputs when value is present
Browse files Browse the repository at this point in the history
This ensures that when another admin is filling a field and the current
admin has a local auto-save restored with an empty value, the current
admin's auto-save will not clear the other admin's value.
  • Loading branch information
thibaudgg committed Nov 4, 2023
1 parent 03b6737 commit 4e960b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/javascript/controllers/admin/auto_save_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default class extends Controller {
for (var pair of form.entries()) {
if (pair[0] != "authenticity_token") {
let editor = this.formTarget.querySelector(`[name='${pair[0]}'] ~ trix-editor`)
if (editor) {
if (editor && !editor.editor.getDocument().isEmpty()) {
data.push([pair[0], JSON.stringify(editor.editor)])
}
else {
else if (pair[1]) {
data.push([pair[0], pair[1]])
}
}
Expand Down

0 comments on commit 4e960b9

Please sign in to comment.