Skip to content

feat: Tree multiple level loading support and only count "items" for collection size #8349

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

Merged
merged 29 commits into from
Jul 11, 2025

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Jun 4, 2025

Closes RSP Component Milestones (view)

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Test Tree multiloading stories in RAC storybook. Also test all collections that support loading indicators (Table, Listbox, GridList, Tree, ComboBox, Picker, etc) and make sure that the virtualized items have the proper aria-rowcount/posinset/etc. Loaders shouldn't be counted as items/rows. Sanity check that other collections work fine virtualized/non-virtualized and that empty states/initial load states still render as expected

🧢 Your Project:

RSP

@rspbot
Copy link

rspbot commented Jun 5, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 5, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 17, 2025

Build successful! 🎉

@LFDanLu LFDanLu changed the title feat: Tree multiple level loading support feat: Tree multiple level loading support and only count "items" for collection size Jun 17, 2025
@rspbot
Copy link

rspbot commented Jun 17, 2025

Build successful! 🎉

snowystinger
snowystinger previously approved these changes Jun 23, 2025
@snowystinger
Copy link
Member

looks like you have some conflicts, happy to help resolve

@rspbot
Copy link

rspbot commented Jun 23, 2025

Build successful! 🎉

snowystinger
snowystinger previously approved these changes Jun 23, 2025
@rspbot
Copy link

rspbot commented Jun 24, 2025

Build successful! 🎉

snowystinger
snowystinger previously approved these changes Jun 26, 2025
@rspbot
Copy link

rspbot commented Jul 7, 2025

devongovett
devongovett previously approved these changes Jul 7, 2025
@LFDanLu LFDanLu dismissed stale reviews from devongovett and snowystinger via eb1aa3c July 8, 2025 16:39
@rspbot
Copy link

rspbot commented Jul 8, 2025

* add docs for gridlist

* add async loading docs for GridList and Listbox adjacent components

* add docs example for table

* add prop tables

* rename sentinel component and add prop tables

* adding tree docs for loading spinners

* fix docs lint

* typo and left over stuff

* export the loadMoreItem props from the monopackage

* review comments

* fix the tree example in docs

* review comments

* review comments

* forgot to remove a delay
@rspbot
Copy link

rspbot commented Jul 8, 2025

devongovett
devongovett previously approved these changes Jul 8, 2025
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple small comments, looks like you have some merge conflicts too

let sentinelRef = useRef(null);
let memoedLoadMoreProps = useMemo(() => ({
onLoadMore,
// TODO: this collection will update anytime a row is expanded/collapsed becaused the flattenedRows will change.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a TODO before merge?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the todo here but keep the comment in case it turns out to be an issue down the line

sentinelRef,
scrollOffset
}), [onLoadMore, scrollOffset, state?.collection]);
UNSTABLE_useLoadMoreSentinel(memoedLoadMoreProps, sentinelRef);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we removing UNSTABLE for all of them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was debating whether or not to do that for this util, but I think I'll go ahead and remove it since it is just a util with a pretty specific purpose (not sure if people will use it tbh)

@rspbot
Copy link

rspbot commented Jul 10, 2025

@rspbot
Copy link

rspbot commented Jul 10, 2025

## API Changes

react-aria-components

/react-aria-components:UNSTABLE_GridListLoadingSentinel

-UNSTABLE_GridListLoadingSentinel <T extends {}> {
-  children?: ReactNode
-  className?: string
-  isLoading?: boolean
-  onLoadMore?: () => any
-  scrollOffset?: number = 1
-  style?: CSSProperties
-}

/react-aria-components:UNSTABLE_ListBoxLoadingSentinel

-UNSTABLE_ListBoxLoadingSentinel <T extends {}> {
-  children?: ReactNode
-  className?: string
-  isLoading?: boolean
-  onLoadMore?: () => any
-  scrollOffset?: number = 1
-  style?: CSSProperties
-}

/react-aria-components:UNSTABLE_TableLoadingSentinel

-UNSTABLE_TableLoadingSentinel <T extends {}> {
-  children?: ReactNode
-  className?: string
-  isLoading?: boolean
-  onLoadMore?: () => any
-  scrollOffset?: number = 1
-  style?: CSSProperties
-}

/react-aria-components:UNSTABLE_TreeLoadingIndicator

-UNSTABLE_TreeLoadingIndicator <T extends {}> {
-  children?: ChildrenOrFunction<UNSTABLE_TreeLoadingIndicatorRenderProps>
-  className?: ClassNameOrFunction<UNSTABLE_TreeLoadingIndicatorRenderProps>
-  style?: StyleOrFunction<UNSTABLE_TreeLoadingIndicatorRenderProps>
-}

/react-aria-components:GridListLoadMoreItem

+GridListLoadMoreItem <T extends {}> {
+  children?: ReactNode
+  className?: string
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: CSSProperties
+}

/react-aria-components:ListBoxLoadMoreItem

+ListBoxLoadMoreItem <T extends {}> {
+  children?: ReactNode
+  className?: string
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: CSSProperties
+}

/react-aria-components:TableLoadMoreItem

+TableLoadMoreItem <T extends {}> {
+  children?: ReactNode
+  className?: string
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: CSSProperties
+}

/react-aria-components:TreeLoadMoreItem

+TreeLoadMoreItem <T extends {}> {
+  children?: ReactNode | ((TreeLoadMoreItemRenderProps & {
+    defaultChildren: ReactNode | undefined
+})) => ReactNode
+  className?: ClassNameOrFunction<TreeLoadMoreItemRenderProps>
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: StyleOrFunction<TreeLoadMoreItemRenderProps>
+}

/react-aria-components:GridListLoadMoreItemProps

+GridListLoadMoreItemProps {
+  children?: ReactNode
+  className?: string
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: CSSProperties
+}

/react-aria-components:ListBoxLoadMoreItemProps

+ListBoxLoadMoreItemProps {
+  children?: ReactNode
+  className?: string
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: CSSProperties
+}

/react-aria-components:TableLoadMoreItemProps

+TableLoadMoreItemProps {
+  children?: ReactNode
+  className?: string
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: CSSProperties
+}

/react-aria-components:TreeLoadMoreItemProps

+TreeLoadMoreItemProps {
+  children?: ReactNode | ((TreeLoadMoreItemRenderProps & {
+    defaultChildren: ReactNode | undefined
+})) => ReactNode
+  className?: ClassNameOrFunction<TreeLoadMoreItemRenderProps>
+  isLoading?: boolean
+  onLoadMore?: () => any
+  scrollOffset?: number = 1
+  style?: StyleOrFunction<TreeLoadMoreItemRenderProps>
+}

/react-aria-components:TreeLoadMoreItemRenderProps

+TreeLoadMoreItemRenderProps {
+  level: number
+}

@react-aria/utils

/@react-aria/utils:UNSTABLE_useLoadMoreSentinel

-UNSTABLE_useLoadMoreSentinel {
-  props: LoadMoreSentinelProps
-  ref: RefObject<HTMLElement | null>
-  returnVal: undefined
-}

/@react-aria/utils:useLoadMoreSentinel

+useLoadMoreSentinel {
+  props: LoadMoreSentinelProps
+  ref: RefObject<HTMLElement | null>
+  returnVal: undefined
+}

@LFDanLu LFDanLu added this pull request to the merge queue Jul 11, 2025
Merged via the queue into main with commit 8326f90 Jul 11, 2025
31 checks passed
@LFDanLu LFDanLu deleted the multi_loader_support branch July 11, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants