"Experimental" autosave on form change is enabled, but doesn't work.

Created on 18 October 2024, 3 months ago

Problem/Motivation

The autosave functionality on form change is not working as expected when the "Run only on form change" setting is enabled. I understand that this feature is currently "experimental" in the current version. This setting is highly requested by Drupal authors I work with as the timing mechanism is good but doesn't capture changes sometimes unless the timer is short.

Note: The provided patch may address specific use cases for my needs only, but I am hopeful that this could initiate a broader discussion towards making the feature more functional for all entities configured for autosave.

Steps to reproduce

  1. Go to the autosave form settings and enable "Run only on form change."
  2. Open a form that supports autosave.
  3. Make changes to the form and observe the behavior.
  4. Note that the form is not autosaved after changes.

Proposed resolution

  • Update the JavaScript logic to correctly track changes in the form.
  • Introduce a debounce mechanism to prevent frequent autosave triggers when minor changes occur.
  • Ensure that CKEditor instances are properly initialized and monitored for changes to trigger autosave.
  • Modify existing functions to correctly identify form changes and trigger autosave accordingly.

Again, the above may target my specific cases. For instance, the patch includes factoring in nested/collapsed paragraphs and some JS included here specifically is to reinitialize the Autosave to work for nested CKEditors.

Part of the patch is merely migrating some functions to a higher level to make it easier to reference elsewhere in the file.

Remaining tasks

  • Test the updated JavaScript functionality on different types of forms, including those with CKEditor fields and paragraph components.
  • Verify that autosave is triggered only when form data changes, and no autosave is triggered when no changes are made.
  • - Confirm that the debounce mechanism works effectively to prevent frequent triggers.

User interface changes

No visible UI changes are expected. However, users should notice a difference in the autosave behavior, where autosaves now occur only when changes are detected.

API changes

No API changes are expected.

Data model changes

No data model changes are expected.

If there happens to be another thread I've missed that targets this specific issue, please tag it here as I couldn't find a thread that relates.

πŸ› Bug report
Status

Active

Version

1.6

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jv24

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024