Skip to content

fix(richtext-lexical): don't reset link drawer form state during lexical updates#16943

Open
harsha-cpp wants to merge 1 commit into
payloadcms:mainfrom
harsha-cpp:fix/autosave-overwrites-link-modal
Open

fix(richtext-lexical): don't reset link drawer form state during lexical updates#16943
harsha-cpp wants to merge 1 commit into
payloadcms:mainfrom
harsha-cpp:fix/autosave-overwrites-link-modal

Conversation

@harsha-cpp

Copy link
Copy Markdown

fixes #15719.

problem: autosave triggers a lexical state update, which calls $updateLinkEditor, which calls setStateData(data) with the node's committed fields. DrawerContent has data in its useEffect dependency array, so every update re-fetches the initial form state — reverting any in-progress edits (e.g. switching link type from custom to internal) back to what's persisted in the lexical node.

fix: expose isOpen from useLexicalDrawer and guard setStateData in $updateLinkEditor. when the drawer is already open, lexical updates no longer overwrite the form's initial state; the drawer only resets when it opens fresh for a new link.

@harsha-cpp harsha-cpp requested a review from AlessioGr as a code owner June 9, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autosave overwrites changes in link modal

1 participant