Skip to content
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

[WIP][lexical-playground] Bug Fix: Layout deletion when it's the first node #7311

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kirandash
Copy link
Contributor

Description

Current behavior:

  • Currently, when a layout is the first node in the editor, selecting all content and deleting (either through keyboard or mouse selection) leads to an invalid state of the widget. This issue only occurs when the layout is the first node - if there's a paragraph before the layout, deletion works correctly.

Changes being added:

  • Added $handleLayoutDelete function in LayoutPlugin to properly handle layout deletion
  • Added command registrations for all delete operations (character, word, line)
  • Added comprehensive e2e tests to verify deletion behavior in various scenarios

Closes #6938

Test plan

Before

lexical-6938-bug.mov

After

The following test cases have been added to verify the fix:

  • Layout deletion when it's the first node
  • Layout deletion with surrounding content
  • Testing different delete operations:
    • Regular delete/backspace
    • Word delete (Ctrl+Backspace)
    • Line delete (Cmd+Backspace)

All tests pass and verify that:

  1. Layout deletion works correctly regardless of its position
  2. Selection and deletion work properly from both inside and outside the layout
  3. Editor maintains a valid state after deletion
lexical-6938-fix.mov

- Added  function in LayoutPlugin to handle layout deletion
  for all delete operations (character, word, line)
- Added command registrations for DELETE_CHARACTER_COMMAND, DELETE_WORD_COMMAND,
  and DELETE_LINE_COMMAND
- Added new e2e tests in Layout.spec.mjs:
  - Layout deletion when it's the first node
  - Layout deletion with surrounding content
  - Testing different delete operations (character, word, line)

Fixes facebook#6938
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 9, 2025
Copy link

vercel bot commented Mar 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2025 0:53am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2025 0:53am

@kirandash kirandash marked this pull request as draft March 9, 2025 12:34
@kirandash kirandash changed the title [lexical-playground] Bug Fix: Layout deletion when it's the first node [WIP][lexical-playground] Bug Fix: Layout deletion when it's the first node Mar 9, 2025
@etrepum
Copy link
Collaborator

etrepum commented Mar 9, 2025

I haven’t looked at this at all yet but usually this type of thing is handled with collapseAtStart rather than command listeners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Columns Layout if first node deletion is incorrect
3 participants