core icon indicating copy to clipboard operation
core copied to clipboard

[TASK] Implement Optimistic Updates in Style Editor for Real-Time Headless Rendering

Open KevinDavilaDotCMS opened this issue 11 months ago • 4 comments

Description

We have a form that lists contentlet configurations with various controls. (Check [TASK] Render Style Editor Form Based on Configuration from @dotcms/uve)

The Goal We need to connect the editing of these styles with the rendered headless page to ensure a seamless user experience. The goal is to implement Optimistic Updates so that when a user makes a change, they see the update in real-time without waiting for network latency.

Technical Requirements

  • Optimistic Mechanism: Create a mechanism to apply changes immediately to the UI.

  • Efficient Updates: Develop an efficient function to replace the new values within the page structure.

  • Backend Synchronization: Ensure the new value is saved to the backend asynchronously after the local update.

  • Rollback Strategy: If the backend save fails, the system must revert to the previous state.

Acceptance Criteria

  • [ ] Real-time Updates: When a user modifies a control in the Style Editor, the change is sent immediately to the headless page via an optimistic update (zero wait time).

  • [ ] Backend Persistence: Trigger a SAVE operation to the backend immediately after the local update.

  • [ ] Error Handling (Rollback):

  • If the SAVE operation fails, the page object must revert to its previous state.

  • The reverted object must be sent back to the headless page to reflect the valid state.

  • The user must be notified of the error.

  • [ ] Success State: If the SAVE does not fail, the workflow continues normally without interrupting the user.

  • [ ] The function responsible for replacing values in the page structure must be optimized for performance to prevent UI lag.

Priority

None

Additional Context

Please review https://github.com/dotCMS/core/issues/33691

KevinDavilaDotCMS avatar Dec 11 '25 19:12 KevinDavilaDotCMS

Note to QA

QA is stopped until to close this task: [TASK] Style Editor Pre-populate Form with Contentlet styleProperties

KevinDavilaDotCMS avatar Jan 07 '26 17:01 KevinDavilaDotCMS

Failed QA

  • dotCMS docker image: [dotcms/dotcms:trunk]

Reason

When the style endpoint call is throwing an HTTP failure, we are not doing the rollback of the style changes

Video

https://github.com/user-attachments/assets/cc6102bd-61aa-439b-92b5-3b4773794472

ihoffmann-dot avatar Jan 23 '26 23:01 ihoffmann-dot

Passed QA

  • dotCMS docker image: [dotcms/dotcms:trunk]

Video

https://github.com/user-attachments/assets/c4928d22-98ff-42cf-af6b-4d72ff2105c5

ihoffmann-dot avatar Jan 27 '26 20:01 ihoffmann-dot