-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add support for tree sections #9013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
473d209
e896397
c3385c1
fb17656
a1c8b17
89df42f
8491826
6f78fe7
43f2895
99d4169
049f2a5
fce9dce
f138f6a
900d69e
ae36ec5
cff1b4c
e6752ca
fb703b2
98289ce
ed55388
3facc4a
2674d5b
19151b4
91cb778
49cb60c
13baafd
100befa
2d98707
fa3da98
2410143
92e1840
8191e58
229092c
bee7804
46d3c76
8f668a2
29e729d
564646d
3d8b288
d209f52
f1088a1
421f22f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ | |
| */ | ||
|
|
||
| import {chain, getScrollParent, mergeProps, scrollIntoViewport, useSlotId, useSyntheticLinkProps} from '@react-aria/utils'; | ||
| import {DOMAttributes, FocusableElement, Key, RefObject, Node as RSNode} from '@react-types/shared'; | ||
| import {Collection, DOMAttributes, FocusableElement, Key, RefObject, Node as RSNode} from '@react-types/shared'; | ||
| import {CollectionNode} from '@react-aria/collections'; | ||
| import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus'; | ||
| import {getRowId, listMap} from './utils'; | ||
| import {HTMLAttributes, KeyboardEvent as ReactKeyboardEvent, useRef} from 'react'; | ||
|
|
@@ -100,11 +101,11 @@ export function useGridListItem<T>(props: AriaGridListItemOptions, state: ListSt | |
|
|
||
| let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined; | ||
| let setSize = 1; | ||
| if (node.level > 0 && node?.parentKey != null) { | ||
| if (node.level >= 0 && node?.parentKey != null) { | ||
LFDanLu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let parent = state.collection.getItem(node.parentKey); | ||
| if (parent) { | ||
| // siblings must exist because our original node exists | ||
| let siblings = state.collection.getChildren?.(parent.key)!; | ||
| let siblings = getDirectChildren(parent as CollectionNode<T>, state.collection as Collection<CollectionNode<T>>); | ||
|
||
| setSize = [...siblings].filter(row => row.type === 'item').length; | ||
| } | ||
| } else { | ||
|
|
@@ -324,3 +325,13 @@ function last(walker: TreeWalker) { | |
| } while (last); | ||
| return next; | ||
| } | ||
|
|
||
| function getDirectChildren<T>(parent: CollectionNode<T>, collection: Collection<CollectionNode<T>>) { | ||
| let node = parent?.firstChildKey != null ? collection.getItem(parent.firstChildKey) : null; | ||
|
||
| let siblings: CollectionNode<T>[] = []; | ||
| while (node) { | ||
| siblings.push(node); | ||
| node = node.nextKey != null ? collection.getItem(node.nextKey) : null; | ||
| } | ||
| return siblings; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.