Skip to content

Commit

Permalink
[lexical-playground] Fix table hover actions button position (faceboo…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivailop7 authored Jan 4, 2025
1 parent bd1ef2a commit 8100d6d
Showing 1 changed file with 21 additions and 2 deletions.
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)
.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

0 comments on commit 8100d6d

Please sign in to comment.