MCPcopy Index your code
hub / github.com/primer/react / getPageSize

Function getPageSize

packages/react/src/TreeView/useRovingTabIndex.ts:217–222  ·  view source on GitHub ↗

* Determine the page size for the given tree based on an item in the tree. We * estimate this size by trying to see how many items will fit in the given * tree. If the tree is within a scroll container, we will use the height of * that container. Otherwise, we'll use the current window height

(root: Element, item: HTMLElement | null)

Source from the content-addressed store, hash-verified

215 * that container. Otherwise, we'll use the current window height
216 */
217function getPageSize(root: Element, item: HTMLElement | null) {
218 const scrollContainer = getScrollContainer(root)
219 const {height: itemHeight} = item?.getBoundingClientRect() ?? defaultSize
220 const availableHeight = scrollContainer?.clientHeight ?? window.innerHeight
221 return Math.floor(availableHeight / itemHeight)
222}
223
224function getNextPageElement(element: HTMLElement): HTMLElement | undefined {
225 const root = element.closest('[role="tree"]')

Callers 2

getNextPageElementFunction · 0.85
getPreviousPageElementFunction · 0.85

Calls 1

getScrollContainerFunction · 0.90

Tested by

no test coverage detected