Skip to content

Commit

Permalink
fix: Make useStickyScrollbar hook react to offset prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Carvalho committed Sep 13, 2023
1 parent d8b1fd0 commit 3b157cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/table/sticky-scrollbar/sticky-scrollbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ function StickyScrollbar(
*/
const { stickyOffsetBottom } = useAppLayoutContext();

useStickyScrollbar(scrollbarRef, scrollbarContentRef, tableRef, wrapperRef, stickyOffsetBottom);

useStickyScrollbar(scrollbarRef, scrollbarContentRef, tableRef, wrapperRef, stickyOffsetBottom, offsetScrollbar);
return (
<div
ref={mergedRef}
Expand Down
4 changes: 0 additions & 4 deletions src/table/sticky-scrollbar/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
margin-top: calc(-1 * awsui.$border-divider-section-width); // -1px to compensate for border width
border-top: awsui.$border-divider-section-width solid awsui.$color-border-divider-default;
}

&.is-visual-refresh {
margin-top: -5px;
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/table/sticky-scrollbar/use-sticky-scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export function useStickyScrollbar(
scrollbarContentRef: RefObject<HTMLDivElement>,
tableRef: RefObject<HTMLTableElement>,
wrapperRef: RefObject<HTMLDivElement>,
footerHeight: number
footerHeight: number,
offsetScrollbar: boolean
) {
// We don't take into account containing-block calculations because that would
// unnecessarily overcomplicate the position logic. For now, we assume that a
Expand Down Expand Up @@ -109,7 +110,15 @@ export function useStickyScrollbar(
observer.disconnect();
};
}
}, [scrollbarContentRef, scrollbarRef, tableRef, wrapperRef, consideredFooterHeight, hasContainingBlock]);
}, [
scrollbarContentRef,
scrollbarRef,
tableRef,
wrapperRef,
consideredFooterHeight,
hasContainingBlock,
offsetScrollbar,
]);

// Update scrollbar position when window resizes (vertically).
useEffect(() => {
Expand Down

0 comments on commit 3b157cc

Please sign in to comment.