Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/__tests__/StickyHeaders.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -671,5 +671,36 @@ describe("StickyHeaders - Compute Function", () => {
}),
});
});

it("should not intercept touches on the full-width container (multi-column gutter)", () => {
const layouts = createStandardLayouts();

const manager = createMockRecyclerViewManager({
scrollOffset: 100,
layouts,
});

const result = render(
<StickyHeaders
stickyHeaderIndices={[0, 10, 20]}
stickyHeaderOffset={0}
data={testData}
scrollY={new Animated.Value(0)}
renderItem={renderItem}
stickyHeaderRef={createRef()}
recyclerViewManager={manager}
extraData={undefined}
onChangeStickyIndex={jest.fn()}
/>
);

// The full-width absolute container must use box-none so the empty gutter
// region in multi-column layouts lets touches pass through to the content
// below while the header content itself stays interactive (issue #2249).
const animatedView = result.find(Animated.View);
expect(animatedView).toHaveReactProps({
pointerEvents: "box-none",
});
});
});
});
5 changes: 5 additions & 0 deletions src/recyclerview/components/StickyHeaders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ export const StickyHeaders = <TItem,>({
const headerContent = useMemo(() => {
return (
<CompatAnimatedView
// The container spans the full row width, so in multi-column layouts its
// empty gutter region would otherwise intercept touches meant for the
// content below. "box-none" makes the container transparent to touches
// while keeping its children (the header content) interactive.
pointerEvents="box-none"
style={{
position: "absolute",
top: stickyHeaderOffset,
Expand Down
Loading