[lexical][lexical-website] Documentation Update: SKIP_DOM_SELECTION_TAG is ignored during initial editor state#8636
Conversation
… state The tag is applied through editor.update() and tags propagate via the in-progress update, but the initial editor state setup runs outside of any user-driven update cycle, so the SKIP_DOM_SELECTION_TAG check never sees the tag and the DOM selection is set on first mount. Document the workaround (`$setSelection(null)` inside the initial state setup function) both in the JSDoc next to SKIP_DOM_SELECTION_TAG and at the Focus section of the website's Selection page, where the tag is already introduced. Per @etrepum's suggestion in the issue thread. Refs facebook#8610
|
Hi @spokodev! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Title and description doesn't match the pull request template |
potatowagon
left a comment
There was a problem hiding this comment.
Reviewed by Navi (Tater Thoughts Bobblehead) on behalf of @potatowagon.
LGTM ✅
What I checked:
- Documentation accuracy: The note correctly documents real behavior —
SKIP_DOM_SELECTION_TAGis indeed ignored during initial editor state setup because the initial reconcile path bypasses the tag-checking logic. - Workaround correctness:
$setSelection(null)inside the initial state function is the correct approach — it prevents selection from being set, so there is nothing to scroll to or focus. - Code example: Well-formed, uses proper
editor.update()pattern inside theeditorStatecallback. - JSDoc comment update in
LexicalUpdateTags.ts: Accurately documents the limitation and the recommended workaround. - No runtime code changes — purely docs + JSDoc, zero risk of regression.
- www compat: No impact — no API changes, no removed/renamed exports.
Assessment: Pure documentation improvement that saves developers from a common gotcha. The SKIP_DOM_SELECTION_TAG limitation on initial state is a known sharp edge (I can see why users would expect it to work), and documenting both the limitation AND the workaround is the right call. CI all green (unit 22.x+24.x, browser, integrity, e2e canary chromium, CLA, Vercel). Ready to approve.
Description
SKIP_DOM_SELECTION_TAGis intentionally a no-op during the initial editor state (whether passed viacreateEditor'seditorStateoption or$initialEditorStateon the root extension): tags only propagate through user-driveneditor.update()calls, and the initial mount runs outside of any such update. That limitation was undocumented, which surfaced as confusion in #8610.This PR documents it in two places, with no runtime behaviour changes:
SKIP_DOM_SELECTION_TAGconstant inpackages/lexical/src/LexicalUpdateTags.tspackages/lexical-website/docs/concepts/selection.md), including the$setSelection(null)workaround for suppressing the initial scroll/focusCloses #8610
Test plan
Before
SKIP_DOM_SELECTION_TAGJSDoc gave no hint that the initial editor state ignores the tag.After
$setSelection(null)pattern.Docs-only change —
pnpm buildis clean across the affected packages, and I read through the rendered JSDoc and the rebuilt website page.