-
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: Selection of table cell is accompanied by selection of adjacent cell too #6973
Comments
There's a workaround for this with RangeSelection (#4512) but the TableObserver code needs to handle it separately. Basically it's a matter of checking the detail property in the event and handling that selection update manually. |
@etrepum when i try the playground link in (#4512) its fixed, but on the current playground its still broken, how do i get to use these changes for my editor? |
The table code back then worked differently, someone has to create a PR with a new fix for this issue. |
Hello @etrepum I see that the logic to select the table cells is this, upon triple clicking a cell we select all the nodes between that cell (anchor node) and its just next cell (focus node), Let me know if you have any questions with this. the cell on which the triple click happened is our anchor node, Approach: If we could just prevent the focus from going to the immediate next cell on triple click we can very likely fix the issue. My questions is: Are we by any chance shifting the focus to the immediate next cell through some code? |
All of the nodes between the anchor and focus of a range selection are selected, just by the definition of what a range selection is. The code you're pointing at is not relevant here. |
The above code gets all the nodes between the anchor and focus and adds it to _cachedNodes which is eventually used by another code in a loop to select nodes. On triple clicking the anchor is our current cell and focus is the next cell, and the range selection selects all the nodes in between. This is my understanding till now. Please correct me if you see a gap. Coming to the expected behavior, On triple click we expect only the current cell to get selected right? Please correct me if I'm wrong. |
Nodes don't "get selected", a selection is created and then set on the editor, nothing happens to the nodes, this code tells you which nodes are in the selection based on the definition of a range selection. When you call selection methods on a node, it creates a selection with points on that node and sets it on the editor. There is no method to go the other way, nothing happens to the nodes when they enter or leave the editor's selection. I'm only commenting on your understanding of the code here. You're looking in the wrong place. If you expect a different set of nodes to be in the selection then the selection needs to be created with different points. |
@etrepum is there any chance if someone from the team can raise a fix for this? |
@jvithlani it's not a priority of mine to work on this but I posted a draft PR that demonstrates the technique that I suggested earlier #7005 - you should be able to add this sort of handler to your own code separate from the table plugin as this is purely additive. |
Currently in the table if we triple click a cell, it will select 2 cells which is a very weird behaviour. If the cell in the last column which is being triple clicked then 2 rows will be selected
Screen.Recording.2024-12-18.at.2.08.37.AM.mov
Lexical version: 0.21.0
Steps To Reproduce
The current behavior
Random selection of table cells on triple click
The expected behavior
Some consistent behaviour which behaves same for all table cells
Impact of fix
The ux around table will be great and consistent
The text was updated successfully, but these errors were encountered: