Skip to content

Experiments panel: 'Unsaved changes' dialog fires on a blank, untouched creation form #37639

Description

@jcastro-dotcms

Problem Statement

When creating a new experiment from the UVE Experiments panel (issue #37478, PR #37485), closing the panel triggers an "Unsaved changes" confirmation dialog even when nothing has been typed into the creation form. This gives editors a false "you'll lose your work" warning on a form that has no work to lose, and it will happen on nearly every open-then-close of the panel's creation screen — which is a very common interaction (an editor opening Experiments just to look, with no page-level experiments yet).

Steps to Reproduce

  1. Enable FEATURE_FLAG_EXPERIMENTS_PORTLET on the instance.
  2. In the Universal Visual Editor, open any page that has no existing experiments.
  3. Click the "A/B" (Experiments) button in the page editor's bottom navigation bar. The panel opens on its empty state.
  4. Click "Create an Experiment for this Page."
  5. Without typing anything into any field (leave Experiment Name, Description, everything blank), click the "Close the Experiments panel" (X) button at the top-right of the panel.

Expected: the panel closes immediately — there is nothing to lose.

Actual: an "Unsaved changes" dialog appears: "This experiment has changes that have not been saved. If you leave now they will be lost."

A related repro worth checking as part of the same root cause: typing into the Experiment Name field and, without clicking anything intended to leave or close, the same dialog can appear on its own a moment later.

Suggested root cause (for whoever picks this up)

The "is this dirty?" check driving the dialog looks like it's evaluating something coarser than "has the user changed a field value" — e.g. "is this experiment a Draft that hasn't been persisted to the backend yet" — rather than comparing current field values against their initial (blank) state. That would explain why any close of a not-yet-saved creation screen trips it, edited or not. Worth checking unsaved-changes.guard.ts (added in PR #37485) and whatever dirty-tracking it reads from.

Acceptance Criteria

  • Closing an untouched, blank creation form does not show the "Unsaved changes" dialog.
  • The dialog still appears correctly when the form genuinely has unsaved edits (e.g. after typing an Experiment Name).

dotCMS Version

Local build from master @ merge commit 9b5dc65bf8bc1ef26a3d5dfba6bab326043afbc9 (PR #37485). Found during manual post-merge testing of issue #37478.

Severity

High - Major functionality broken (interrupts a very common interaction with a false data-loss warning)

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions