Skip to content

Commit 68659b8

Browse files
committed
fix: improve table action button visibility logic
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.
1 parent 74f16ac commit 68659b8

File tree

1 file changed

+9
-14
lines changed
  • packages/lexical-playground/src/plugins/TableActionMenuPlugin

1 file changed

+9
-14
lines changed

packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx

+9-14
Original file line numberDiff line numberDiff line change
@@ -803,14 +803,6 @@ function TableCellActionMenuContainer({
803803

804804
const checkTableCellOverflow = useCallback(
805805
(tableCellParentNodeDOM: HTMLElement): boolean => {
806-
// Check if the cell is overflowed by checking the element directly
807-
const isOverflowed =
808-
tableCellParentNodeDOM.scrollWidth >
809-
tableCellParentNodeDOM.clientWidth ||
810-
tableCellParentNodeDOM.scrollHeight >
811-
tableCellParentNodeDOM.clientHeight;
812-
813-
// Check if the cell is within the visible bounds of its scrollable container
814806
const scrollableContainer = tableCellParentNodeDOM.closest(
815807
'.PlaygroundEditorTheme__tableScrollableWrapper',
816808
);
@@ -820,17 +812,20 @@ function TableCellActionMenuContainer({
820812
).getBoundingClientRect();
821813
const cellRect = tableCellParentNodeDOM.getBoundingClientRect();
822814

823-
// Check if the cell's right edge is beyond the container's right edge
824-
// or if the cell's left edge is before the container's left edge
815+
// Calculate where the action button would be positioned (5px from right edge of cell)
816+
// Also account for the button width (20px) and its right margin (5px)
817+
const actionButtonRight = cellRect.right - 5;
818+
const actionButtonLeft = actionButtonRight - 20;
819+
820+
// Only hide if the action button would overflow the container
825821
if (
826-
cellRect.right > containerRect.right ||
827-
cellRect.left < containerRect.left
822+
actionButtonRight > containerRect.right ||
823+
actionButtonLeft < containerRect.left
828824
) {
829825
return true;
830826
}
831827
}
832-
833-
return isOverflowed;
828+
return false;
834829
},
835830
[],
836831
);

0 commit comments

Comments
 (0)