-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: Add more Autocomplete examples #7827
Conversation
…ete-example # Conflicts: # packages/react-aria-components/docs/Autocomplete.mdx
@@ -487,14 +488,19 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions | |||
if (focusedKey == null && !shouldUseVirtualFocus && ref.current) { | |||
focusSafely(ref.current); | |||
} | |||
|
|||
// Wait until the collection has items to autofocus. |
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.
Previously we delayed rendering the menu until the collection had items, but we can't do this anymore now that we have empty state support. Instead, delay auto focusing until the collection is filled.
## API Changes
react-aria-components/react-aria-components:Menu Menu <T extends {}> {
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children?: ReactNode | ({}) => ReactNode
- className?: string
+ className?: string | ((MenuRenderProps & {
+ defaultClassName: string | undefined
+})) => string
defaultSelectedKeys?: 'all' | Iterable<Key>
dependencies?: ReadonlyArray<any>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
+ renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
slot?: string | null
- style?: CSSProperties
+ style?: CSSProperties | ((MenuRenderProps & {
+ defaultStyle: CSSProperties
+})) => CSSProperties | undefined
} /react-aria-components:MenuProps MenuProps <T> {
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children?: ReactNode | (T) => ReactNode
- className?: string
+ className?: string | ((MenuRenderProps & {
+ defaultClassName: string | undefined
+})) => string
defaultSelectedKeys?: 'all' | Iterable<Key>
dependencies?: ReadonlyArray<any>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
+ renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
slot?: string | null
- style?: CSSProperties
+ style?: CSSProperties | ((MenuRenderProps & {
+ defaultStyle: CSSProperties
+})) => CSSProperties | undefined
} @react-spectrum/s2/@react-spectrum/s2:Menu Menu <T extends {}> {
UNSAFE_className?: string
UNSAFE_style?: CSSProperties
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children: ReactNode | ({}) => ReactNode
defaultSelectedKeys?: 'all' | Iterable<Key>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
hideLinkOutIcon?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
+ renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
size?: 'S' | 'M' | 'L' | 'XL' = 'M'
styles?: StylesProp
} /@react-spectrum/s2:MenuProps MenuProps <T> {
UNSAFE_className?: string
UNSAFE_style?: CSSProperties
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children: ReactNode | (T) => ReactNode
defaultSelectedKeys?: 'all' | Iterable<Key>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
hideLinkOutIcon?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
+ renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
size?: 'S' | 'M' | 'L' | 'XL' = 'M'
styles?: StylesProp
} |
Do we want to expose |
<XIcon aria-hidden className="w-4 h-4" /> | ||
</Button> | ||
</SearchField> | ||
<ListBox items={languages} className="outline-hidden p-1 overflow-auto flex-1 scroll-pb-1"> |
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.
Should we add renderEmptyState
to the two examples?
Seems like a good idea, though we could also add it later if we're unsure right |
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.
Do we want a card for Autocomplete at the bottom here with the other components?
https://reactspectrum.blob.core.windows.net/reactspectrum/1395e6852d2255e581c5aa7cd75f91f734a66d1c/docs/react-aria/examples/searchable-select.html
eventually yes. maybe once it is GA? we don't have the card for the home pages yet which is usually what we use here |
Adds a styled Searchable Select example. Also adds an async loading example to the docs, and added
renderEmptyState
to menu to support this. Removed the "State" example because the clear button is already in the search field so didn't seem necessary.Updated text of the features section to specifically mention some of the UI patterns that can be built with Autocomplete, and tried to describe the difference with ComboBox.