-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: DELETE_CHARACTER_COMMAND pushes meaningless history #5350
Comments
And also before-heading.movI wonder why we have to make a new // lexical-rich-text/src/index.ts L371
// now
collapseAtStart(): true {
const newElement = !this.isEmpty()
? $createHeadingNode(this.getTag())
: $createParagraphNode();
const children = this.getChildren();
children.forEach((child) => newElement.append(child));
this.replace(newElement);
return true;
}
// what about this ?
collapseAtStart(): true {
if (!this.isEmpty()) {
return true;
}
const newElement = $createParagraphNode();
const children = this.getChildren();
children.forEach((child) => newElement.append(child));
this.replace(newElement);
return true;
} |
- Simplify HeadingNode's collapseAtStart to prevent unnecessary node recreation - Return early when no actual changes are needed - Fixes facebook#5350 - DELETE_CHARACTER_COMMAND pushing meaningless history entries
- Fix test assertion for backspace at start of heading with no content - Fix test assertion for backspace at start of heading with content - Add multiple backspace operations to verify no history pollution - Properly verify undo behavior reverts to previous meaningful state Part of fix for facebook#5350 - DELETE_CHARACTER_COMMAND pushing meaningless history
Lexical version: latest
Steps To Reproduce
DELETE
orBACKSPACE
on the very first position (offset === 0) with collapsed selection, without any content and sibling (i.e. empty editor).DELETE_CHARACTER_COMMAND
that has done nothing.Link to code example: can reproduce it on playground.
The current behavior
before.mov
The expected behavior
It should work as it has some content:
DELETE
orBACKSPACE
command which does nothing doesn't push historyexpected.mov
The text was updated successfully, but these errors were encountered: