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

[lexical-table] Bug Fix: cannot delete content when a table inside selection #6412

Merged
merged 3 commits into from
Jul 28, 2024
Merged

Conversation

placeba
Copy link
Contributor

@placeba placeba commented Jul 17, 2024

$deleteCellHandler blocks content removing.

Steps To Reproduce

Test Case #1:

  1. Open playground
  2. Type any text
  3. Insert a 5x5 table
  4. Select all
  5. Press 'Backspace' or 'Delete'

Text cannot be removed.

Test Case #2

  1. Open playground
  2. Insert a sample image
  3. Insert a 5x5 table
  4. Select a sample image
  5. Press 'Backspace' or 'Delete'

A sample image cannot be removed.

Copy link

vercel bot commented Jul 17, 2024

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 Jul 28, 2024 10:14pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2024 10:14pm

@facebook-github-bot
Copy link
Contributor

Hi @placeba!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

github-actions bot commented Jul 17, 2024

size-limit report 📦

Path Size
lexical - cjs 29.05 KB (0%)
lexical - esm 28.86 KB (0%)
@lexical/rich-text - cjs 37.39 KB (0%)
@lexical/rich-text - esm 28.33 KB (0%)
@lexical/plain-text - cjs 36.02 KB (0%)
@lexical/plain-text - esm 25.6 KB (0%)
@lexical/react - cjs 39.29 KB (0%)
@lexical/react - esm 29.77 KB (0%)

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Jul 17, 2024
ivailop7
ivailop7 previously approved these changes Jul 17, 2024
Copy link
Collaborator

@ivailop7 ivailop7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Jul 17, 2024
@ivailop7
Copy link
Collaborator

@placeba Your newly added test is failing, otherwise looks good. Please fix your test case and happy to merge.

@placeba
Copy link
Contributor Author

placeba commented Jul 18, 2024

@ivailop7 $deleteCellHandler removes a table in a selection and then tries to select next node (nextNode.selectStart()).
The test fails because Firefox cannot handle with a new selection.

I can suggest removing these lines:

  if (nextNode) {
	nextNode.selectStart();
  } else {
	parentNode.selectStart();
  }

@ivailop7
Copy link
Collaborator

This fix is actually a bit more involved. Your solution breaks deletion for a few patterns, if you have text and table is the very last node, the editor crashes. If you have the table in the middle of the text, Ctrl + A, delete, it doesn't delete all the text outside of the table. If table is the first node and followed by text, Ctrl +A, delete also doesn't delete cleanly.

@ivailop7
Copy link
Collaborator

ivailop7 commented Jul 27, 2024

@serey-roth this regression was introduced with #6274, any suggestions for fixing this one?

@serey-roth
Copy link
Contributor

serey-roth commented Jul 27, 2024

@serey-roth this regression was introduced with #6274, any suggestions for fixing this one?

@ivailop7 Removing the node selection after deleting, as @placeba suggested, should do it.

https://www.loom.com/share/901cf1b9dc3446fd8afe1dac34e0afc0?sid=9cf05a3c-0c92-4438-8b85-bb5efcbb5fce

@ivailop7
Copy link
Collaborator

@serey-roth this regression was introduced with #6274, any suggestions for fixing this one?

@ivailop7 Removing the node selection after deleting, as @placeba suggested, should do it.

Raised #6471

@ivailop7
Copy link
Collaborator

@placeba can you incorporate the changes from #6471 and then I'll merge your original PR.

@ivailop7 ivailop7 added this pull request to the merge queue Jul 28, 2024
Merged via the queue into facebook:main with commit 01d7d0a Jul 28, 2024
44 checks passed
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. extended-tests Run extended e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants