Skip to content

Tiptap RTE: Ignore no-op transactions in onUpdate to prevent phantom dirty state (closes #22767) - #22781

Merged
leekelleher merged 1 commit into
v17/devfrom
v17/bugfix/22767-rte-save-discard-changes
May 11, 2026
Merged

Tiptap RTE: Ignore no-op transactions in onUpdate to prevent phantom dirty state (closes #22767)#22781
leekelleher merged 1 commit into
v17/devfrom
v17/bugfix/22767-rte-save-discard-changes

Conversation

@AndyButland

@AndyButland AndyButland commented May 8, 2026

Copy link
Copy Markdown
Contributor

Description

After creating a blank document with a Rich Text Editor property and clicking Save (without making any changes), the Discard Changes dialog appears spuriously when the workspace redirects from /create to /edit/<id>.

Fixes #22767.

This looks to be happening due to a toggle of the readonly property on <umb-input-tiptap> around save that's considered a meaningful update to content.

To fix I've guarded onUpdate with if (!transaction.docChanged) return;. Real user edits are always doc-changing transactions, so they are unaffected. Only the no-op transactions Tiptap emits for editor-state changes (like setEditable) are filtered out.

Testing

  • Create a Document Type with a Rich Text Editor property.
  • Create new content based on it and leave the RTE blank.
  • Click Save — the Discard Changes dialog should NOT appear.
  • Type some content in the RTE, then navigate away without saving — the Discard Changes dialog SHOULD still appear.
  • Save & Publish on a blank RTE — should continue to work as before

Copilot AI review requested due to automatic review settings May 8, 2026 15:34
@claude

claude Bot commented May 8, 2026

Copy link
Copy Markdown

Claude finished @AndyButland's task in 1m 44s —— View job


PR Review

Target: origin/v17/dev · Based on commit: 35fca74c · Skipped: 0 noise files out of 1 total

Guards the Tiptap onUpdate callback against no-op transactions (e.g. those emitted by setEditable), preventing phantom workspace dirty state after save.

  • Other changes: Save-then-redirect no longer spuriously opens the Discard Changes dialog when the RTE was left blank.

Suggestions

  • src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts:229: No automated regression test is included. The onUpdate guard is the kind of quiet behavioral fix that is easy to accidentally revert. A browser-based component test (using @web/test-runner as described in docs/testing.md) that mocks a setEditable call and asserts no UmbChangeEvent is dispatched would lock in the fix without requiring manual verification every release.

Approved with Suggestions for improvement

Good to go, but please carefully consider the importance of the suggestions.

The fix is minimal, correct, and well-scoped. transaction.docChanged is the idiomatic ProseMirror/Tiptap way to distinguish real content mutations from editor-state-only transactions (focus, editability, selection), so the guard is reliable. The comment explaining the non-obvious Tiptap behavior is appropriate and aligns with the repo's comment policy.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents the Backoffice workspace from being marked “dirty” by Tiptap “update” events that do not actually modify the document (e.g., the no-op transaction emitted when toggling editability during save), addressing the phantom “Discard Changes” dialog after creating and saving blank RTE content.

Changes:

  • Update the Tiptap onUpdate handler to ignore transactions where transaction.docChanged is false, preventing no-op editor state changes from dispatching UmbChangeEvent.

@claude claude Bot added area/frontend category/ux User experience labels May 8, 2026
@leekelleher
leekelleher self-requested a review May 11, 2026 11:12
@leekelleher
leekelleher merged commit cd476ab into v17/dev May 11, 2026
35 of 36 checks passed
@leekelleher
leekelleher deleted the v17/bugfix/22767-rte-save-discard-changes branch May 11, 2026 13:13
leekelleher pushed a commit that referenced this pull request May 11, 2026
…dirty state (closes #22767) (#22781)

Ignore Tiptap no-op transactions in onUpdate to prevent phantom dirty state.

(cherry picked from commit cd476ab)
AndyButland added a commit that referenced this pull request Jun 5, 2026
…dirty state (closes #22767) (#22781)

Ignore Tiptap no-op transactions in onUpdate to prevent phantom dirty state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants