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 Fix: Shift+down selects an extra subsequent element for Table selection #6679

Merged
merged 17 commits into from
Oct 16, 2024

Conversation

KatsiarynaDzibrova
Copy link
Contributor

@KatsiarynaDzibrova KatsiarynaDzibrova commented Sep 27, 2024

Description

Only the table should be selected when shift+down. Also fixes scenario when selection is stuck when trying to unselect a table with arrow keys.

Closes #6527 for Tables

Test plan

Before

Paragraph after table is selected
table-selection-shiftdown-before

After

Only table is selected
table-selection-shiftdown-after

Before

Selection stuck
table-unselect-shiftdown-before

After

Can unselect tables one by one
table-unselect-shiftdown-after

Copy link

vercel bot commented Sep 27, 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 Oct 16, 2024 3:14pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2024 3:14pm

@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 Sep 27, 2024
Copy link

github-actions bot commented Sep 27, 2024

size-limit report 📦

Path Size
lexical - cjs 29.94 KB (0%)
lexical - esm 29.78 KB (0%)
@lexical/rich-text - cjs 38.51 KB (0%)
@lexical/rich-text - esm 31.58 KB (0%)
@lexical/plain-text - cjs 37.16 KB (0%)
@lexical/plain-text - esm 29 KB (0%)
@lexical/react - cjs 40.29 KB (0%)
@lexical/react - esm 33 KB (0%)

focusNode,
(n) => $isElementNode(n) && !n.isInline(),
);
if ($isTableCellNode(focusParentNode)) {
focusParentNode = getParentTable(focusParentNode);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just $findMatchingParent(focusParentNode, $isTableNode), but needing that extra helper method, it will return the table node or null, just like your method.

Cursor should stop inside first/last cell of table not on the paragraph before/after the table
focusOffset: 0,
focusPath: [2],
focusOffset: 1,
focusPath: [1, 2, 1],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Focus will now be inside the last cell of the table, not on the next element after table

Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

It still seems possible to get "stuck" if you remove any elements between the tables

For example, using this document with two tables and a paragraph, if you focus the last paragraph and then press shift up it works to select the first table but not the second

the third part takes care of changing selection already. This part also has a bug: the case of selecting table using shift+up (not down) is not handled which makes selection stuck
@KatsiarynaDzibrova
Copy link
Contributor Author

Addressed your comment in 0a47177

Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Seems to work great now! Very nice improvement

@etrepum etrepum added this pull request to the merge queue Oct 16, 2024
Merged via the queue into facebook:main with commit 24e8341 Oct 16, 2024
39 of 40 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.

Bug: Shift+down selects an extra subsequent element
4 participants