Skip to content

Commit

Permalink
fix: window scrolling in grouped mode
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Jan 4, 2023
1 parent f249026 commit aa4df5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions examples/window-group-scroll.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as React from 'react'
import { GroupedVirtuoso } from '../src'

export function Example() {
return (
<GroupedVirtuoso
useWindowScroll
groupCounts={Array.from({ length: 20 }).fill(3) as number[]}
itemContent={(index) => <div style={{ height: '20px' }}>Item {index}</div>}
groupContent={(index) => <div style={{ height: '30px', backgroundColor: 'gray' }}>Group {index}</div>}
style={{ height: '300px' }}
/>
)
}
2 changes: 1 addition & 1 deletion src/hooks/useChangedChildSizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function useChangedListContentsSizes(
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const windowScrolling = (scrollableElement.firstElementChild! as HTMLDivElement).dataset['viewportType']! === 'window'
const windowScrolling = (scrollableElement.lastElementChild! as HTMLDivElement).dataset['viewportType']! === 'window'

const scrollTop = customScrollParent
? customScrollParent.scrollTop
Expand Down

0 comments on commit aa4df5a

Please sign in to comment.