-
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
[lexical-playground] Bug Fix: Table action menu visibility with cell overflow #7334
[lexical-playground] Bug Fix: Table action menu visibility with cell overflow #7334
Conversation
- Fixed table action menu visibility check for partially visible cells - Added test coverage for menu visibility when: - Cell has no overflow (visible) - Cell is partially visible due to column resize (hidden) Fixes facebook#7331
Remove redundant HTMLElement type assertions in checkTableCellOverflow since tableCellParentNodeDOM is already typed as HTMLElement
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Restore accidentally deleted table markup in 'Resize merged cells height' test. This reverts part of the previous commit that unintentionally removed the test setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does generally solve the problem but there is a small issue in that we don't update this position when scrolling (not a regression, it occurs before this PR as well). You can reproduce by selecting a fully visible cell and then scrolling the table (the menu stays in place but the cell moves) or selecting an overflowed cell and then scrolling it to be fully visible (no menu appears).
Since this PR strictly makes forward progress I'm inclined to merge as-is, and handling scrolling or revisiting the popover strategy in a more systematic way would make sense.
Generally speaking we have a lot of popover related issues in the playground because none of them are quite implemented correctly
popover
It would make sense to finish up #6923 or do something equivalent to that eventually.
Alternatively it might also be possible to do something in the internal getDOMSlot API (#6759) to allow managed portals to be attached to the end of ElementNode and then ignored by the reconciler and mutation observer… but that would require a lot more thought since it has to tie in with the createDOM/updateDOM lifecycle as well (elements can be destroyed and re-created at any time).
Looks like some e2e test need to be addressed
Something I hadn't considered when I created this issue is that the action button can also overflow on the left hand side when a small portion of the cell is still visible on the left. |
The table action menu positioning has issues in collab mode's split view. Skip the test in collab mode following the pattern of other table UI tests until the underlying positioning issue in TableActionMenuPlugin is fixed.
Previously, the table action menu would only hide when a cell overflowed on the right side of the scrollable container. This update extends the overflow check to also hide the menu when a cell overflows on the left side, ensuring consistent behavior for partially visible cells in both directions. Changes: - Updated checkTableCellOverflow to check for left side overflow - Added cellRect.left < containerRect.left condition alongside right edge check
The table action menu visibility test was failing in Firefox due to click event handling issues. Mark the test as fixme for Firefox since the clicks work manually but are unreliable in automated tests. This is a temporary fix until the underlying click event handling in Firefox can be properly addressed.
Thanks for catching this! I've updated the Let me know if you notice any other edge cases that need to be addressed! |
@etrepum Thank you for the detailed feedback. I understand there are still underlying issues with popover positioning during scrolling that need to be addressed more systematically. And I agree that completing #6923 would be the right long-term fix. For now, I've focused on fixing the immediate e2e test failures to unblock the pipeline, but I'll look into contributing to the systematic popover positioning solution which is WIP as well. I've fixed the failing e2e test for the table action menu visibility in two ways:
|
Thanks for looking into it. Ideally we'd only hide the action button on left overflow if the actual button is overflowing. Currently it sounds like the button won't get displayed if even the slightest bit of cell is overflowing from the left which wouldn't be ideal since the action button is placed on the right. |
Previously, the action button would hide when any part of the cell overflowed. Now it only hides when the button itself would be inaccessible: - Calculate actual button position (5px from right edge) - Account for button width (20px) - Hide only if button would overflow container bounds - Check both left and right edges of button for visibility This makes the button more accessible while still preventing UI issues when the button would be partially hidden.
Refined the action button position calculation to include: - Button width (20px) - Cell padding (8px) - Right margin (5px) Total offset is now 28px from right edge This ensures the button is properly positioned and visible within the cell's boundaries, preventing any overflow issues.
Thanks for the feedback! I've updated the logic to be more precise about when to hide the action button. Now it only hides when the button itself would be inaccessible, rather than when any part of the cell overflows. The button's position (5px from right edge), width (20px), table cell padding (8px) are taken into account to ensure it remains visible whenever there's enough space for it to be fully displayed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I think eventually we will be able to come up with a better solution for this sort of thing (that puts this sort of UI inside the document DOM) with some combination of getDOMSlot and/or setDOMUnmanaged but those are not really public APIs yet.
Description
Current behavior:
Currently, the table action menu button remains visible even when a cell is partially visible due to overflow, as reported in issue #7331. This creates a confusing user experience since the menu appears for cells that are not fully in view.
Changes being added:
This PR improves the table action menu visibility check by properly handling cell overflow in the scrollable container. The menu is now correctly hidden when a cell is partially visible and reappears when scrolled into full view.
Technical Changes:
Created
checkTableCellOverflow
inTableActionMenuPlugin
to:Added E2E test to verify:
Closes #7331
Test plan
Before
lexical-bug-7331.mp4
After
Table action menu is hidden when cell overflows
lexical-7331-fix.mov