hide sticky table group after scrolling past

This commit is contained in:
jeffvli
2025-11-16 15:22:00 -08:00
parent 2bdb5a52c4
commit 21081edfa3
@@ -1,3 +1,4 @@
import { useInView } from 'motion/react';
import { useEffect, useMemo, useState } from 'react';
import { useWindowSettings } from '/@/renderer/store/settings.store';
@@ -32,6 +33,15 @@ export const useStickyTableGroupRows = ({
const { windowBarStyle } = useWindowSettings();
const [stickyGroupIndex, setStickyGroupIndex] = useState<null | number>(null);
const topMargin =
windowBarStyle === Platform.WINDOWS || windowBarStyle === Platform.MACOS
? '-130px'
: '-100px';
const isTableInView = useInView(containerRef, {
margin: `${topMargin} 0px 0px 0px`,
});
const stickyTop = useMemo(() => {
// If sticky header is showing, position group row below it with 1px offset to avoid conflict
// Otherwise, use the base sticky position
@@ -169,8 +179,12 @@ export const useStickyTableGroupRows = ({
stickyTop,
]);
const shouldShowStickyGroupRow = useMemo(() => {
return enabled && stickyGroupIndex !== null && isTableInView;
}, [enabled, stickyGroupIndex, isTableInView]);
return {
shouldShowStickyGroupRow: stickyGroupIndex !== null,
shouldShowStickyGroupRow,
stickyGroupIndex,
stickyTop,
};