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-playground] Fix table hover actions button position #7011

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix Table Hover Actions button position
  • Loading branch information
ivailop7 committed Jan 1, 2025
commit 02fc22a68f90624a0d705f237f8fa4a9cf6bed86
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ function TableHoverActionsContainer({
height: tableElemHeight,
} = (tableDOMElement as HTMLTableElement).getBoundingClientRect();

// Adjust for using the scrollable table container
const parentElement = (tableDOMElement as HTMLTableElement)
Copy link
Collaborator

Choose a reason for hiding this comment

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

A more robust check here would be to compare tableDOMElement to parentElement = editor.getElementByKey(table.getKey()) - if they are not identical, then the latter is the outermost wrapping node. This is already computed above just not saved to its own variable.

.parentElement;
let tableHasScroll = false;
if (
parentElement &&
parentElement.classList.contains(
'PlaygroundEditorTheme__tableScrollableWrapper',
)
) {
tableHasScroll =
parentElement.scrollWidth > parentElement.clientWidth;
}
const {y: editorElemY, left: editorElemLeft} =
anchorElem.getBoundingClientRect();

Expand All @@ -123,9 +136,15 @@ function TableHoverActionsContainer({
setShownRow(true);
setPosition({
height: BUTTON_WIDTH_PX,
left: tableElemLeft - editorElemLeft,
left:
tableHasScroll && parentElement
? parentElement.offsetLeft
: tableElemLeft - editorElemLeft,
top: tableElemBottom - editorElemY + 5,
width: tableElemWidth,
width:
tableHasScroll && parentElement
? parentElement.offsetWidth
: tableElemWidth,
});
} else if (hoveredColumnNode) {
setShownColumn(true);
Expand Down
Loading