-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Tree multiple level loading support #8299
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
base: main
Are you sure you want to change the base?
Conversation
… the top most collection
{/* TODO: wonder if there is something we can do to ensure that these depenedcies are provided, need to dig to make sure if there is an alternative */} | ||
{/* NOTE: important to provide dependencies here, otherwise the nested level doesn't perform loading updates properly */} | ||
<Collection items={rootData.items} dependencies={[isProjectsLoading, isDocumentsLoading, isProjectsLevel3Loading]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a bit gross but is required to make sure the loading spinner in a nested row is properly updated when its loading state updates
Build successful! 🎉 |
Build successful! 🎉 |
## API Changes
react-aria-components/react-aria-components:UNSTABLE_TreeLoadingIndicator-UNSTABLE_TreeLoadingIndicator <T extends {}> {
- children?: ReactNode | ((UNSTABLE_TreeLoadingIndicatorRenderProps & {
- defaultChildren: ReactNode | undefined
-})) => ReactNode
- className?: string | ((UNSTABLE_TreeLoadingIndicatorRenderProps & {
- defaultClassName: string | undefined
-})) => string
- style?: CSSProperties | ((UNSTABLE_TreeLoadingIndicatorRenderProps & {
- defaultStyle: CSSProperties
-})) => CSSProperties | undefined
-} /react-aria-components:UNSTABLE_TreeLoadingSentinel+UNSTABLE_TreeLoadingSentinel <T extends {}> {
+ children?: ReactNode | ((UNSTABLE_TreeLoadingSentinelRenderProps & {
+ defaultChildren: ReactNode | undefined
+})) => ReactNode
+ className?: string | ((UNSTABLE_TreeLoadingSentinelRenderProps & {
+ defaultClassName: string | undefined
+})) => string
+ isLoading?: boolean
+ onLoadMore?: () => any
+ scrollOffset?: number = 1
+ style?: CSSProperties | ((UNSTABLE_TreeLoadingSentinelRenderProps & {
+ defaultStyle: CSSProperties
+})) => CSSProperties | undefined
+} |
let focusedItem = tree.getItem(selectionState.focusedKey); | ||
// TODO: do we want to have the same logic as useListState/useGridState where it tries to find the nearest row? | ||
// We could possibly special case this loader case and have it try to find the item just before it/the parent | ||
if (!focusedItem || focusedItem.type === 'loader' && !focusedItem.props.isLoading) { | ||
selectionState.setFocusedKey(null); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I've preserved the previous behavior of just focusing the tree if the loader disappears, but ideally we'd do something like useListState and useGridState where it looks for the closest focusable row as a substitute. Will handle that update upon refactoring some of that logic as noted in https://github.com/adobe/react-spectrum/pull/8326/files#r2116825740
let memoedLoadMoreProps = useMemo(() => ({ | ||
onLoadMore, | ||
// TODO: this collection will update anytime a row is expanded/collapsed becaused the flattenedRows will change. | ||
// This means onLoadMore will trigger but that might be ok cause the user should have logic to handle multiple loadMore calls | ||
collection: state?.collection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think this should be ok, but open to discuss
Closes
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: