fix(editor): Prevent section Backspace from deleting sections with non-text content#3220
Draft
bukinoshita wants to merge 1 commit intocanaryfrom
Draft
fix(editor): Prevent section Backspace from deleting sections with non-text content#3220bukinoshita wants to merge 1 commit intocanaryfrom
bukinoshita wants to merge 1 commit intocanaryfrom
Conversation
…ontent The isSectionEmpty heuristic only checked textContent and content.size, which caused sections containing leaf/atom nodes (e.g. dividers, images) to be misclassified as empty. Pressing Backspace would then delete the entire section despite it having visible content. The fix adds a check for leaf child nodes (isLeaf covers both atom nodes and self-closing nodes like horizontalRule). If any child is a leaf node, the section is not considered empty. Extracts isSectionEmpty into its own utility file with unit tests. Resolves BU-667 Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
|
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary by cubic
Prevents Backspace from deleting sections that contain dividers, images, or other leaf/atom blocks. Addresses Linear BU-667.
isSectionEmptyto return false if any child is a leaf node (isLeaf), includinghorizontalRuleand atom nodes.isSectionEmptytopackages/editor/src/utils/is-section-empty.tsand wired it into the section extension.horizontalRule, atom nodes, and mixed content.Written for commit 7e77dea. Summary will update on new commits.