Skip to content

Commit

Permalink
Fix #5508/#5487: TreeTable scrollable fixes (#5511)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Dec 4, 2023
1 parent c4f5a70 commit 6e8730c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions components/lib/treetable/TreeTableScrollableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export const TreeTableScrollableView = React.memo((props) => {
frozenScrollBody = DomHandler.findSingle(frozenView, '.p-treetable-scrollable-body');
}

scrollHeaderBoxRef.current.style.marginLeft = -1 * scrollBodyRef.current.scrollLeft + 'px';
scrollHeaderBoxRef.current.style.transform = `translateX(-${scrollBodyRef.current.scrollLeft}px)`;

if (scrollFooterBoxRef.current) {
scrollFooterBoxRef.current.style.marginLeft = -1 * scrollBodyRef.current.scrollLeft + 'px';
scrollFooterBoxRef.current.style.transform = `translateX(-${scrollBodyRef.current.scrollLeft}px)`;
}

if (frozenScrollBody) {
Expand All @@ -78,16 +78,20 @@ export const TreeTableScrollableView = React.memo((props) => {
};

useMountEffect(() => {
if (!props.frozen) {
const scrollBarWidth = DomHandler.calculateScrollbarWidth();
let el = DomHandler.find(findDataTableContainer(elementRef.current), '[data-pc-section="scrollablebody"]');

el = el.length > 1 ? el[1] : el[0];

const scrollBarWidth = DomHandler.calculateScrollbarWidth(el);

if (!props.frozen) {
scrollHeaderBoxRef.current.style.marginRight = scrollBarWidth + 'px';

if (scrollFooterBoxRef.current) {
scrollFooterBoxRef.current.style.marginRight = scrollBarWidth + 'px';
}
} else {
scrollBodyRef.current.style.paddingBottom = DomHandler.calculateScrollbarWidth() + 'px';
scrollBodyRef.current.style.paddingBottom = scrollBarWidth + 'px';
}
});

Expand Down

0 comments on commit 6e8730c

Please sign in to comment.