Skip to content
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

docs: RAC Tree docs #7730

Merged
merged 26 commits into from
Feb 20, 2025
Merged

docs: RAC Tree docs #7730

merged 26 commits into from
Feb 20, 2025

Conversation

snowystinger
Copy link
Member

Closes

Modelled on Table docs

✅ 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:

🧢 Your Project:

@rspbot
Copy link

rspbot commented Feb 6, 2025

@rspbot
Copy link

rspbot commented Feb 12, 2025

@rspbot
Copy link

rspbot commented Feb 13, 2025

@rspbot
Copy link

rspbot commented Feb 13, 2025

@snowystinger snowystinger changed the title [WIP]: docs: RAC Tree docs docs: RAC Tree docs Feb 13, 2025
@snowystinger snowystinger marked this pull request as ready for review February 13, 2025 07:30

## Examples

<ExampleList tag="tree" />
Copy link
Member

Choose a reason for hiding this comment

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

Chevron does not pass contrast in light mode. Maybe the background and text color is what should be changed in light mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

can you provide a screenshot? I'm not noticing anything and axe dev tools isn't showing me anything

Copy link
Member

Choose a reason for hiding this comment

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

Screenshot 2025-02-14 at 11 14 53 AM

Copy link
Member

Choose a reason for hiding this comment

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

the selection highlight color also fails contrast vs the background since there is no checkbox (it's 2.35:1).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I believe I've met the contrast requirements now, selection is 3.74:1 and text on selection is now 4.77:1

@rspbot
Copy link

rspbot commented Feb 13, 2025

@rspbot
Copy link

rspbot commented Feb 14, 2025

@rspbot
Copy link

rspbot commented Feb 14, 2025

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

we need to add the card to react-aria/components.mdx and react-spectrum/index.mdx as well


## Examples

<ExampleList tag="tree" />
Copy link
Member

Choose a reason for hiding this comment

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

the selection highlight color also fails contrast vs the background since there is no checkbox (it's 2.35:1).


### Hooks

If you need to customize things even further, such as accessing internal state or customizing DOM structure, you can drop down to the lower level Hook-based API. See [useTree](useTree.html) for more details.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like useTree docs don't exist. Should also be useTreeGridList also?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is when I messaged you about how we don't have those docs yet, so I'll work on creating them next. For now I'll just comment this section out

@@ -18,11 +18,11 @@ import {
Provider,
TreeItemProps as RACTreeItemProps,
TreeProps as RACTreeProps,
Tree,
TreeItem,
TreeItemContent,
Copy link
Member

@yihuiliao yihuiliao Feb 14, 2025

Choose a reason for hiding this comment

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

noticed a couple things in the stories while testing:

1. the focus ring doesn't sit on top of the selected item very well when isDetached is true (nvm, seems like it's fixed in virtualizer docs so it all just needs to get merged)

Screen.Recording.2025-02-14.at.2.09.55.PM.mov
  1. the focus ring appears on selection when i use my mouse to click. maybe usePress related and not anything in this PR in particular. also happens in RAC Tree but not in V3 TreeView
Screen.Recording.2025-02-14.at.2.08.16.PM.mov

@rspbot
Copy link

rspbot commented Feb 16, 2025

@rspbot
Copy link

rspbot commented Feb 17, 2025

@rspbot
Copy link

rspbot commented Feb 17, 2025

@rspbot
Copy link

rspbot commented Feb 17, 2025

@rspbot
Copy link

rspbot commented Feb 19, 2025

@rspbot
Copy link

rspbot commented Feb 19, 2025

@rspbot
Copy link

rspbot commented Feb 19, 2025

@rspbot
Copy link

rspbot commented Feb 19, 2025

@snowystinger
Copy link
Member Author

Starters in verdaccio build, see 0da9de6#comments

@rspbot
Copy link

rspbot commented Feb 19, 2025

devongovett
devongovett previously approved these changes Feb 20, 2025
reidbarber
reidbarber previously approved these changes Feb 20, 2025
# Conflicts:
#	packages/@react-spectrum/s2/src/TreeView.tsx
#	packages/react-aria-components/stories/Tree.stories.tsx
#	packages/react-aria-components/test/Tree.test.tsx
@snowystinger snowystinger dismissed stale reviews from reidbarber and devongovett via e6e088e February 20, 2025 02:11
@rspbot
Copy link

rspbot commented Feb 20, 2025

@rspbot
Copy link

rspbot commented Feb 20, 2025

## API Changes

react-aria-components

/react-aria-components:UNSTABLE_TreeLoadingIndicator

-UNSTABLE_TreeLoadingIndicator <T extends {}> {
-  children?: ReactNode | ((TreeLoadingIndicatorRenderProps & {
-    defaultChildren: ReactNode | undefined
-})) => ReactNode
-  className?: string | ((TreeLoadingIndicatorRenderProps & {
-    defaultClassName: string | undefined
-})) => string
-  style?: CSSProperties | ((TreeLoadingIndicatorRenderProps & {
-    defaultStyle: CSSProperties
-})) => CSSProperties | undefined
-}

/react-aria-components:UNSTABLE_Tree

-UNSTABLE_Tree <T extends {}> {
-  aria-describedby?: string
-  aria-details?: string
-  aria-label?: string
-  aria-labelledby?: string
-  autoFocus?: boolean | FocusStrategy
-  children?: ReactNode | ({}) => ReactNode
-  className?: string | ((TreeRenderProps & {
-    defaultClassName: string | undefined
-})) => string
-  defaultExpandedKeys?: Iterable<Key>
-  defaultSelectedKeys?: 'all' | Iterable<Key>
-  dependencies?: ReadonlyArray<any>
-  disabledBehavior?: DisabledBehavior = 'all'
-  disabledKeys?: Iterable<Key>
-  disallowEmptySelection?: boolean
-  expandedKeys?: Iterable<Key>
-  id?: string
-  items?: Iterable<T>
-  onAction?: (Key) => void
-  onExpandedChange?: (Set<Key>) => any
-  onScroll?: (UIEvent<Element>) => void
-  onSelectionChange?: (Selection) => void
-  renderEmptyState?: (TreeEmptyStateRenderProps) => ReactNode
-  selectedKeys?: 'all' | Iterable<Key>
-  selectionBehavior?: SelectionBehavior
-  selectionMode?: SelectionMode
-  slot?: string | null
-  style?: CSSProperties | ((TreeRenderProps & {
-    defaultStyle: CSSProperties
-})) => CSSProperties | undefined
-}

/react-aria-components:UNSTABLE_TreeItem

-UNSTABLE_TreeItem <T extends {}> {
-  aria-label?: string
-  children: ReactNode
-  className?: string | ((TreeItemRenderProps & {
-    defaultClassName: string | undefined
-})) => string
-  download?: boolean | string
-  hasChildItems?: boolean
-  href?: Href
-  hrefLang?: string
-  id?: Key
-  onHoverChange?: (boolean) => void
-  onHoverEnd?: (HoverEvent) => void
-  onHoverStart?: (HoverEvent) => void
-  ping?: string
-  referrerPolicy?: HTMLAttributeReferrerPolicy
-  rel?: string
-  routerOptions?: RouterOptions
-  style?: CSSProperties | ((TreeItemRenderProps & {
-    defaultStyle: CSSProperties
-})) => CSSProperties | undefined
-  target?: HTMLAttributeAnchorTarget
-  textValue: string
-  value?: {}
-}

/react-aria-components:UNSTABLE_TreeContext

-UNSTABLE_TreeContext {
-  UNTYPED
-}

/react-aria-components:UNSTABLE_TreeItemContent

-UNSTABLE_TreeItemContent {
-  children?: ReactNode | ((T & {
-    defaultChildren: ReactNode | undefined
-})) => ReactNode
-}

/react-aria-components:UNSTABLE_TreeStateContext

-UNSTABLE_TreeStateContext {
-  UNTYPED
-}

/react-aria-components:TreeItemProps

 TreeItemProps <T = {}> {
   aria-label?: string
   children: ReactNode
   className?: string | ((TreeItemRenderProps & {
     defaultClassName: string | undefined
 })) => string
   download?: boolean | string
   hasChildItems?: boolean
   href?: Href
   hrefLang?: string
   id?: Key
+  isDisabled?: boolean
+  onAction?: () => void
   onHoverChange?: (boolean) => void
   onHoverEnd?: (HoverEvent) => void
   onHoverStart?: (HoverEvent) => void
   ping?: string
   rel?: string
   routerOptions?: RouterOptions
   style?: CSSProperties | ((TreeItemRenderProps & {
     defaultStyle: CSSProperties
 })) => CSSProperties | undefined
   target?: HTMLAttributeAnchorTarget
   textValue: string
   value?: T
 }

/react-aria-components:TreeItemRenderProps

 TreeItemRenderProps {
+  hasChildItems: boolean
+  id: Key
   isDisabled: boolean
   isExpanded: boolean
   isFocusVisible: boolean
   isFocusVisibleWithin: boolean
   isFocused: boolean
   isHovered: boolean
   isPressed: boolean
   isSelected: boolean
+  level: number
   selectionBehavior: SelectionBehavior
   selectionMode: SelectionMode
+  state: TreeState<unknown>
 }

/react-aria-components:TreeItemContentRenderProps

 TreeItemContentRenderProps {
-  allowsDragging?: boolean
   hasChildItems: boolean
   id: Key
   isDisabled: boolean
-  isDragging?: boolean
-  isDropTarget?: boolean
   isExpanded: boolean
   isFocusVisible: boolean
   isFocusVisibleWithin: boolean
   isFocused: boolean
   isPressed: boolean
   isSelected: boolean
   level: number
   selectionBehavior: SelectionBehavior
   selectionMode: SelectionMode
   state: TreeState<unknown>
 }

/react-aria-components:TreeLoadingIndicator

+TreeLoadingIndicator <T extends {}> {
+  children?: ReactNode | ((TreeLoadingIndicatorRenderProps & {
+    defaultChildren: ReactNode | undefined
+})) => ReactNode
+  className?: string | ((TreeLoadingIndicatorRenderProps & {
+    defaultClassName: string | undefined
+})) => string
+  style?: CSSProperties | ((TreeLoadingIndicatorRenderProps & {
+    defaultStyle: CSSProperties
+})) => CSSProperties | undefined
+}

/react-aria-components:Tree

+Tree <T extends {}> {
+  aria-describedby?: string
+  aria-details?: string
+  aria-label?: string
+  aria-labelledby?: string
+  autoFocus?: boolean | FocusStrategy
+  children?: ReactNode | ({}) => ReactNode
+  className?: string | ((TreeRenderProps & {
+    defaultClassName: string | undefined
+})) => string
+  defaultExpandedKeys?: Iterable<Key>
+  defaultSelectedKeys?: 'all' | Iterable<Key>
+  dependencies?: ReadonlyArray<any>
+  disabledBehavior?: DisabledBehavior = 'all'
+  disabledKeys?: Iterable<Key>
+  disallowEmptySelection?: boolean
+  expandedKeys?: Iterable<Key>
+  id?: string
+  items?: Iterable<T>
+  onAction?: (Key) => void
+  onExpandedChange?: (Set<Key>) => any
+  onScroll?: (UIEvent<Element>) => void
+  onSelectionChange?: (Selection) => void
+  renderEmptyState?: (TreeEmptyStateRenderProps) => ReactNode
+  selectedKeys?: 'all' | Iterable<Key>
+  selectionBehavior?: SelectionBehavior
+  selectionMode?: SelectionMode
+  slot?: string | null
+  style?: CSSProperties | ((TreeRenderProps & {
+    defaultStyle: CSSProperties
+})) => CSSProperties | undefined
+}

/react-aria-components:TreeItem

+TreeItem <T extends {}> {
+  aria-label?: string
+  children: ReactNode
+  className?: string | ((TreeItemRenderProps & {
+    defaultClassName: string | undefined
+})) => string
+  download?: boolean | string
+  hasChildItems?: boolean
+  href?: Href
+  hrefLang?: string
+  id?: Key
+  isDisabled?: boolean
+  onAction?: () => void
+  onHoverChange?: (boolean) => void
+  onHoverEnd?: (HoverEvent) => void
+  onHoverStart?: (HoverEvent) => void
+  ping?: string
+  referrerPolicy?: HTMLAttributeReferrerPolicy
+  rel?: string
+  routerOptions?: RouterOptions
+  style?: CSSProperties | ((TreeItemRenderProps & {
+    defaultStyle: CSSProperties
+})) => CSSProperties | undefined
+  target?: HTMLAttributeAnchorTarget
+  textValue: string
+  value?: {}
+}

/react-aria-components:TreeContext

+TreeContext {
+  UNTYPED
+}

/react-aria-components:TreeItemContent

+TreeItemContent {
+  children?: ReactNode | ((T & {
+    defaultChildren: ReactNode | undefined
+})) => ReactNode
+}

/react-aria-components:TreeStateContext

+TreeStateContext {
+  UNTYPED
+}

@react-spectrum/s2

/@react-spectrum/s2:TreeViewItem

 TreeViewItem <T extends {}> {
   aria-label?: string
   childItems?: Iterable<{}>
   children: ReactNode
   download?: boolean | string
   hasChildItems?: boolean
   href?: Href
   hrefLang?: string
   id?: Key
+  isDisabled?: boolean
+  onAction?: () => void
   onHoverChange?: (boolean) => void
   onHoverEnd?: (HoverEvent) => void
   onHoverStart?: (HoverEvent) => void
   ping?: string
   rel?: string
   routerOptions?: RouterOptions
   target?: HTMLAttributeAnchorTarget
   textValue: string
   value?: T
 }

/@react-spectrum/s2:TreeItemContent

-TreeItemContent {
-
-}

/@react-spectrum/s2:TreeViewItemProps

 TreeViewItemProps <T extends {} = {}> {
   aria-label?: string
   childItems?: Iterable<{}>
   children: ReactNode
   download?: boolean | string
   hasChildItems?: boolean
   href?: Href
   hrefLang?: string
   id?: Key
+  isDisabled?: boolean
+  onAction?: () => void
   onHoverChange?: (boolean) => void
   onHoverEnd?: (HoverEvent) => void
   onHoverStart?: (HoverEvent) => void
   ping?: string
   rel?: string
   routerOptions?: RouterOptions
   target?: HTMLAttributeAnchorTarget
   textValue: string
   value?: T
 }

/@react-spectrum/s2:TreeViewItemContent

+TreeViewItemContent {
+
+}

@react-spectrum/tree

/@react-spectrum/tree:TreeViewItem

 TreeViewItem <T extends {}> {
   aria-label?: string
   childItems?: Iterable<{}>
   children: ReactNode
   download?: boolean | string
   hasChildItems?: boolean
   href?: Href
   hrefLang?: string
   id?: Key
+  isDisabled?: boolean
+  onAction?: () => void
   ping?: string
   referrerPolicy?: HTMLAttributeReferrerPolicy
   rel?: string
   routerOptions?: RouterOptions
   textValue: string
 }

/@react-spectrum/tree:TreeItemContent

-TreeItemContent {
-
-}

/@react-spectrum/tree:SpectrumTreeViewItemProps

 SpectrumTreeViewItemProps <T extends {} = {}> {
   aria-label?: string
   childItems?: Iterable<{}>
   children: ReactNode
   download?: boolean | string
   hasChildItems?: boolean
   href?: Href
   hrefLang?: string
   id?: Key
+  isDisabled?: boolean
+  onAction?: () => void
   ping?: string
   referrerPolicy?: HTMLAttributeReferrerPolicy
   rel?: string
   routerOptions?: RouterOptions
   textValue: string
 }

/@react-spectrum/tree:TreeViewItemContent

+TreeViewItemContent {
+
+}

@snowystinger snowystinger added this pull request to the merge queue Feb 20, 2025
Merged via the queue into main with commit 90bc6c0 Feb 20, 2025
30 checks passed
@snowystinger snowystinger deleted the rac-tree-docs branch February 20, 2025 03:05
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.

5 participants