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

Bug: Columns Layout if first node deletion is incorrect #6938

Open
ivailop7 opened this issue Dec 10, 2024 · 4 comments · May be fixed by #7311
Open

Bug: Columns Layout if first node deletion is incorrect #6938

ivailop7 opened this issue Dec 10, 2024 · 4 comments · May be fixed by #7311

Comments

@ivailop7
Copy link
Collaborator

Lexical 0.21

If the columns layout widget is the first node, Select all (or mouse selection of the whole widget)-> Delete, leads to invalid state of the widget. If there's a paragraph before the widget it select all deletes correctly.

Screen.Recording.2024-12-10.at.23.46.10.mov
@ivailop7
Copy link
Collaborator Author

@basile-savouret this might be a continuation of the original issue you started fixing with the widget

@etrepum
Copy link
Collaborator

etrepum commented Dec 11, 2024

This is mostly due to the point normalization in our $selectAll() function, it basically always shrinks selections down to the innermost element or TextNode if there is one. Maybe we could change that to only shrink if there is a TextNode, or only if the container is ParagraphNode, or something like that. The alternative would be to do something around how delete works, but then you run into the ambiguity of "did they mean to select all the text, or also the container?" - the normalization makes these two intents indistinguishable.

@pawangiri
Copy link

I just ran into this today. Any workarounds?

@etrepum
Copy link
Collaborator

etrepum commented Dec 15, 2024

You could override SELECT_ALL_COMMAND and create a selection that includes the whole node without using $selectAll or selection normalization.

kirandash added a commit to bgwebagency/lexical that referenced this issue Mar 9, 2025
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants