Skip to content

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

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

harsha-cpp wants to merge 3 commits 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
@AlessioGr AlessioGr self-assigned this Jun 19, 2026
@AlessioGr
AlessioGr requested a review from denolfe as a code owner June 20, 2026 00:24

@AlessioGr AlessioGr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unfortunately this doesn't fix the issue. I added a failing e2e test

This branch has not been deployed

No deployments
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

2 participants