Fix decorator input selection#3491
Merged
Merged
Conversation
trueadm
requested review from
acywatson,
fantactuka,
thegreatercurve,
tylerjbainbridge and
zurfyx
as code owners
December 5, 2022 13:23
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
fantactuka
reviewed
Dec 5, 2022
fantactuka
approved these changes
Dec 5, 2022
Co-authored-by: Maksim Horbachevsky <[email protected]>
fantactuka
reviewed
Dec 5, 2022
| }, | ||
| () => { | ||
| target.selectionStart = selectionStart; | ||
| target.selectionEnd = selectionEnd; |
Collaborator
There was a problem hiding this comment.
It's a bit weird pattern to follow as it might be hard to add selection restoration in more complex embeds. I thought lexical would avoid handling input completely when selection is within decorator input.
Collaborator
Author
There was a problem hiding this comment.
I guess you could avoid doing this if you marked the update as discrete too. However, I've had to do this in React before, it's because the setState for React is async from the change event AFAIK.
Merged
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Jun 11, 2026
…ew findings, add tests and docs Addresses the issues identified in review of the SelectBlockExtension PR: - Bail out of the SELECT_ALL_COMMAND listener for commands bubbled from nested editors when cascadeSelection is off (the default), so a stale parent selection can no longer hijack select all from a nested editor - Expand a selection that already spans multiple blocks directly to the whole document instead of shrinking it to the anchor's block - Store a clone() snapshot of the selectAll selection; the live selection object can be mutated in place by later updates, aliasing prevSelectionAll and swallowing the next select all - Select all even when the selection is anchored directly on the root (previously a no-op when prevSelectionAll was set) - Guard against an empty NodeSelection instead of throwing - Keep the PreventSelectAllExtension dependency's disabled state in sync with SelectBlockExtension so disabling the feature disables all of it - Import PreventSelectAllExtension directly instead of via the package barrel (circular import), and drop redundant $setSelection() wrappers around ElementNode.select() - Rename extensions to the majority '@lexical/extension/*' name convention - Restore the PollComponent input caret workaround from facebook#3491 that was removed without explanation or test coverage Tests: - New unit suite for $isBlockFullySelected, block/document select all progression, multi-block expansion, root-anchored selections, node selections, disabled config and PreventSelectAll coupling, nested editor handling with cascadeSelection on and off, and the PreventSelectAll input/textarea behavior (4 of these fail against the previous implementation) - New e2e test for multi-block selection expansion Docs: - Add SelectBlockExtension and PreventSelectAllExtension to included-extensions.md and fill in the other missing entries (@lexical/clipboard, @lexical/html, and the rest of @lexical/extension), omitting deprecated extensions https://claude.ai/code/session_013LyjzFTiTDhbaNe3Tadiqo
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Jun 11, 2026
…kExtension review findings, add tests and docs Addresses the issues identified in review of the SelectBlockExtension PR: - Promote $isBlockFullySelected to @lexical/utils using the caret-based containment implementation from facebook#8666 (simplified with $getCaretRangeInDirection), which handles ancestor element points and empty blocks consistently; it accepts a RangeSelection or CaretRange so the clearFormatting use case in facebook#8666 can adopt it as well - Bail out of the SELECT_ALL_COMMAND listener for commands bubbled from nested editors when cascadeSelection is off (the default), so a stale parent selection can no longer hijack select all from a nested editor - Expand a selection that already spans multiple blocks directly to the whole document instead of shrinking it to the anchor's block - Store a clone() snapshot of the selectAll selection; the live selection object can be mutated in place by later updates, aliasing prevSelectionAll and swallowing the next select all - Select all even when the selection is anchored directly on the root (previously a no-op when prevSelectionAll was set) - Guard against an empty NodeSelection instead of throwing - Keep the PreventSelectAllExtension dependency's disabled state in sync with SelectBlockExtension so disabling the feature disables all of it - Import PreventSelectAllExtension directly instead of via the package barrel (circular import), and drop redundant $setSelection() wrappers around ElementNode.select() - Rename extensions to the majority '@lexical/extension/*' name convention - Restore the PollComponent input caret workaround from facebook#3491 that was removed without explanation or test coverage Tests: - New @lexical/utils unit suite for $isBlockFullySelected covering containment semantics, ancestor element points, backward selections, CaretRange input, trailing decorators, empty and nested blocks - New unit suite for SelectBlockExtension: block/document select all progression, multi-block expansion, root-anchored selections, node selections, disabled config and PreventSelectAll coupling, nested editor handling with cascadeSelection on and off (including an empty nested editor), and the PreventSelectAll input/textarea behavior - New e2e test for multi-block selection expansion Docs: - Add SelectBlockExtension and PreventSelectAllExtension to included-extensions.md and fill in the other missing entries (@lexical/clipboard, @lexical/html, and the rest of @lexical/extension), omitting deprecated extensions https://claude.ai/code/session_013LyjzFTiTDhbaNe3Tadiqo
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Jun 11, 2026
…kExtension review findings, add tests and docs Addresses the issues identified in review of the SelectBlockExtension PR: - Promote $isBlockFullySelected to @lexical/utils using the caret-based containment implementation from facebook#8666 (simplified with $getCaretRangeInDirection), which handles ancestor element points and empty blocks consistently; it accepts a RangeSelection or CaretRange so the clearFormatting use case in facebook#8666 can adopt it as well - Remove the prevSelectionAll snapshot in favor of a stateless $isBlockFullySelected($getRoot(), selection) check. The stored selection could go stale and swallow select all (e.g. a collaborator appending a paragraph while the document was fully selected), and the live selection object could be mutated in place by later updates, aliasing the snapshot - Bail out of the SELECT_ALL_COMMAND listener for commands bubbled from nested editors when cascadeSelection is off (the default), so a stale parent selection can no longer hijack select all from a nested editor - Expand a selection that already spans multiple blocks directly to the whole document instead of shrinking it to the anchor's block - Select all even when the selection is anchored directly on the root - Guard against an empty NodeSelection instead of throwing - Keep the PreventSelectAllExtension dependency's disabled state in sync with SelectBlockExtension so disabling the feature disables all of it - Import PreventSelectAllExtension directly instead of via the package barrel (circular import), and drop redundant $setSelection() wrappers around ElementNode.select() - Rename extensions to the majority '@lexical/extension/*' name convention - Restore the PollComponent input caret workaround from facebook#3491 that was removed without explanation or test coverage Tests: - New @lexical/utils unit suite for $isBlockFullySelected covering containment semantics, ancestor element points, backward selections, CaretRange input, trailing decorators, empty and nested blocks - New unit suite for SelectBlockExtension: block/document select all progression, multi-block expansion, root-anchored selections, select all after concurrent document changes, node selections, disabled config and PreventSelectAll coupling, nested editor handling with cascadeSelection on and off (including an empty nested editor), and the PreventSelectAll input/textarea behavior - New e2e test for multi-block selection expansion Docs: - Add SelectBlockExtension and PreventSelectAllExtension to included-extensions.md and fill in the other missing entries (@lexical/clipboard, @lexical/html, and the rest of @lexical/extension), omitting deprecated extensions https://claude.ai/code/session_013LyjzFTiTDhbaNe3Tadiqo
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Jun 11, 2026
…kExtension review findings, add tests and docs Addresses the issues identified in review of the SelectBlockExtension PR: - Promote $isBlockFullySelected to @lexical/utils using the caret-based containment implementation from facebook#8666 (simplified with $getCaretRangeInDirection), which handles ancestor element points and empty blocks consistently; it accepts a RangeSelection or CaretRange so the clearFormatting use case in facebook#8666 can adopt it as well - Remove the prevSelectionAll snapshot in favor of a stateless $isBlockFullySelected($getRoot(), selection) check. The stored selection could go stale and swallow select all (e.g. a collaborator appending a paragraph while the document was fully selected), and the live selection object could be mutated in place by later updates, aliasing the snapshot - Bail out of the SELECT_ALL_COMMAND listener for commands bubbled from nested editors when cascadeSelection is off (the default), so a stale parent selection can no longer hijack select all from a nested editor - Expand a selection that already spans multiple blocks directly to the whole document instead of shrinking it to the anchor's block - Select all even when the selection is anchored directly on the root - Guard against an empty NodeSelection instead of throwing - Keep the PreventSelectAllExtension dependency's disabled state in sync with SelectBlockExtension so disabling the feature disables all of it - Import PreventSelectAllExtension directly instead of via the package barrel (circular import), and drop redundant $setSelection() wrappers around ElementNode.select() - Rename extensions to the majority '@lexical/extension/*' name convention - Restore the PollComponent input caret workaround from facebook#3491 that was removed without explanation or test coverage Tests: - New @lexical/utils unit suite for $isBlockFullySelected covering containment semantics, ancestor element points, backward selections, CaretRange input, trailing decorators, empty and nested blocks - New unit suite for SelectBlockExtension: block/document select all progression (including single-block documents), multi-block expansion, root-anchored selections, select all after concurrent document changes, preservation of manually created full selections, node selections, disabled config and PreventSelectAll coupling, nested editor handling with cascadeSelection on and off (including an empty nested editor), and the PreventSelectAll input/textarea behavior - New e2e test for multi-block selection expansion Docs: - Add SelectBlockExtension and PreventSelectAllExtension to included-extensions.md and fill in the other missing entries (@lexical/clipboard, @lexical/html, and the rest of @lexical/extension), omitting deprecated extensions https://claude.ai/code/session_013LyjzFTiTDhbaNe3Tadiqo
etrepum
pushed a commit
to levensta/lexical
that referenced
this pull request
Jun 11, 2026
…kExtension review findings, add tests and docs Addresses the issues identified in review of the SelectBlockExtension PR: - Promote $isBlockFullySelected to @lexical/utils using the caret-based containment implementation from facebook#8666 (simplified with $getCaretRangeInDirection), which handles ancestor element points and empty blocks consistently; it accepts a RangeSelection or CaretRange so the clearFormatting use case in facebook#8666 can adopt it as well - Remove the prevSelectionAll snapshot in favor of a stateless $isBlockFullySelected($getRoot(), selection) check. The stored selection could go stale and swallow select all (e.g. a collaborator appending a paragraph while the document was fully selected), and the live selection object could be mutated in place by later updates, aliasing the snapshot - Bail out of the SELECT_ALL_COMMAND listener for commands bubbled from nested editors when cascadeSelection is off (the default), so a stale parent selection can no longer hijack select all from a nested editor - Expand a selection that already spans multiple blocks directly to the whole document instead of shrinking it to the anchor's block - Select all even when the selection is anchored directly on the root - Guard against an empty NodeSelection instead of throwing - Keep the PreventSelectAllExtension dependency's disabled state in sync with SelectBlockExtension so disabling the feature disables all of it - Import PreventSelectAllExtension directly instead of via the package barrel (circular import), and drop redundant $setSelection() wrappers around ElementNode.select() - Rename extensions to the majority '@lexical/extension/*' name convention - Restore the PollComponent input caret workaround from facebook#3491 that was removed without explanation or test coverage Tests: - New @lexical/utils unit suite for $isBlockFullySelected covering containment semantics, ancestor element points, backward selections, CaretRange input, trailing decorators, empty and nested blocks - New unit suite for SelectBlockExtension: block/document select all progression (including single-block documents), multi-block expansion, root-anchored selections, select all after concurrent document changes, preservation of manually created full selections, node selections, disabled config and PreventSelectAll coupling, nested editor handling with cascadeSelection on and off (including an empty nested editor), and the PreventSelectAll input/textarea behavior - New e2e test for multi-block selection expansion Docs: - Add SelectBlockExtension and PreventSelectAllExtension to included-extensions.md and fill in the other missing entries (@lexical/clipboard, @lexical/html, and the rest of @lexical/extension), omitting deprecated extensions https://claude.ai/code/session_013LyjzFTiTDhbaNe3Tadiqo
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Jun 11, 2026
…kExtension review findings, add tests and docs Addresses the issues identified in review of the SelectBlockExtension PR: - Promote $isBlockFullySelected to @lexical/utils using the caret-based containment implementation from facebook#8666 (simplified with $getCaretRangeInDirection), which handles ancestor element points and empty blocks consistently; it accepts a RangeSelection or CaretRange so the clearFormatting use case in facebook#8666 can adopt it as well - Remove the prevSelectionAll snapshot in favor of a stateless $isBlockFullySelected($getRoot(), selection) check. The stored selection could go stale and swallow select all (e.g. a collaborator appending a paragraph while the document was fully selected), and the live selection object could be mutated in place by later updates, aliasing the snapshot - Bail out of the SELECT_ALL_COMMAND listener for commands bubbled from nested editors when cascadeSelection is off (the default), so a stale parent selection can no longer hijack select all from a nested editor - Expand a selection that already spans multiple blocks directly to the whole document instead of shrinking it to the anchor's block - Select all even when the selection is anchored directly on the root - Guard against an empty NodeSelection instead of throwing - Keep the PreventSelectAllExtension dependency's disabled state in sync with SelectBlockExtension so disabling the feature disables all of it - Import PreventSelectAllExtension directly instead of via the package barrel (circular import), and drop redundant $setSelection() wrappers around ElementNode.select() - Rename extensions to the majority '@lexical/extension/*' name convention - Restore the PollComponent input caret workaround from facebook#3491 that was removed without explanation or test coverage Tests: - New @lexical/utils unit suite for $isBlockFullySelected covering containment semantics, ancestor element points, backward selections, CaretRange input, trailing decorators, empty and nested blocks - New unit suite for SelectBlockExtension: block/document select all progression (including single-block documents), multi-block expansion, root-anchored selections, select all after concurrent document changes, preservation of manually created full selections, node selections, disabled config and PreventSelectAll coupling, nested editor handling with cascadeSelection on and off (including an empty nested editor), and the PreventSelectAll input/textarea behavior - New e2e test for multi-block selection expansion Docs: - Add SelectBlockExtension and PreventSelectAllExtension to included-extensions.md and fill in the other missing entries (@lexical/clipboard, @lexical/html, and the rest of @lexical/extension), omitting deprecated extensions https://claude.ai/code/session_013LyjzFTiTDhbaNe3Tadiqo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns out we had a strange bug in
isSelectionCapturedInDecoratorInput. Fixes #3488.