Skip to content

Commit

Permalink
Ensure overflow is measured after density change
Browse files Browse the repository at this point in the history
  • Loading branch information
laratran committed Oct 30, 2024
1 parent c65a6ea commit ee45661
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}

.root-cell-hover-reveal {
overflow: visible
overflow: visible;
}

.cell-hover-reveal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,13 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
useLayoutEffect(() => {
const div = cellHoverRevealDivRef.current;
if (div) {
const isOverflow = div.scrollWidth > div.clientWidth;
setIsCellContentOverflowing(isOverflow);
// Use setTimeout(0) to ensure DOM is fully updated before measuring overflow
setTimeout(() => {
const isOverflow = div.scrollWidth > div.clientWidth;
setIsCellContentOverflowing(isOverflow);
}, 0);
}
}, [cell]);
}, [cell, density]);

const renderCellContent = () => {
if (cell.getIsPlaceholder()) {
Expand Down Expand Up @@ -326,8 +329,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
<> ({row.subRows?.length})</>
)}
</>
)
)}
))}
</>
</TableTd>
);
Expand Down

0 comments on commit ee45661

Please sign in to comment.