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

(WIP) SearchableMenu with persistent item focus #7248

Closed
wants to merge 3 commits into from

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Oct 23, 2024

Closes

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

@LFDanLu LFDanLu mentioned this pull request Oct 23, 2024
5 tasks
Comment on lines +279 to +283
// arrows because the NVDA blue focus indicator moves into the menu and is only restored back to the input when typing. In Voiceover it works just fine though,
// mobile screen readers don't suffer from this when using virtual keyboards either
// When adding the "auto focus the first item if no items are focused" behavior, the announcement of the letter typed gets cut off a bit in NVDA.
// Ariakit seems to announce a bit better, doesn't interrupt.
// Also it feels like we are pulling in more and more stuff/updating focused key in more places, might be nice if this was more centralized
Copy link
Member Author

Choose a reason for hiding this comment

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

the announcement behavior in NVDA is actually bit more nuanced that this depending if the newly focused item is the same as before, will need more testing

@rspbot
Copy link

rspbot commented Oct 23, 2024

@rspbot
Copy link

rspbot commented Oct 24, 2024

@rspbot
Copy link

rspbot commented Oct 28, 2024

@rspbot
Copy link

rspbot commented Oct 28, 2024

## API Changes

react-aria-components

/react-aria-components:Autocomplete

+Autocomplete {
+  aria-describedby?: string
+  aria-details?: string
+  aria-label?: string
+  aria-labelledby?: string
+  autoFocus?: boolean
+  children?: ReactNode | ((AutocompleteRenderProps & {
+    defaultChildren: ReactNode | undefined
+})) => ReactNode
+  className?: string | ((AutocompleteRenderProps & {
+    defaultClassName: string | undefined
+})) => string
+  defaultFilter?: (string, string) => boolean
+  defaultInputValue?: string
+  id?: string
+  inputValue?: string
+  isDisabled?: boolean
+  isReadOnly?: boolean
+  name?: string
+  onBlur?: (FocusEvent<HTMLInputElement>) => void
+  onFocus?: (FocusEvent<HTMLInputElement>) => void
+  onFocusChange?: (boolean) => void
+  onInputChange?: (string) => void
+  onKeyDown?: (KeyboardEvent) => void
+  onKeyUp?: (KeyboardEvent) => void
+  slot?: string | null
+  style?: CSSProperties | ((AutocompleteRenderProps & {
+    defaultStyle: CSSProperties
+})) => CSSProperties | undefined
+}

@react-aria/autocomplete

/@react-aria/autocomplete:useAutocomplete

+useAutocomplete <T> {
+  props: AriaAutocompleteOptions
+  state: AutocompleteState
+  returnVal: undefined
+}

/@react-aria/autocomplete:AriaAutocompleteProps

+AriaAutocompleteProps {
+  aria-describedby?: string
+  aria-details?: string
+  aria-label?: string
+  aria-labelledby?: string
+  autoFocus?: boolean
+  children: ReactNode
+  defaultInputValue?: string
+  description?: ReactNode
+  errorMessage?: ReactNode | (ValidationResult) => ReactNode
+  id?: string
+  inputValue?: string
+  isDisabled?: boolean
+  isReadOnly?: boolean
+  label?: ReactNode
+  name?: string
+  onBlur?: (FocusEvent<HTMLInputElement>) => void
+  onFocus?: (FocusEvent<HTMLInputElement>) => void
+  onFocusChange?: (boolean) => void
+  onInputChange?: (string) => void
+  onKeyDown?: (KeyboardEvent) => void
+  onKeyUp?: (KeyboardEvent) => void
+  placeholder?: string
+}

/@react-aria/autocomplete:AriaAutocompleteOptions

+AriaAutocompleteOptions {
+  aria-describedby?: string
+  aria-details?: string
+  aria-label?: string
+  aria-labelledby?: string
+  autoFocus?: boolean
+  defaultInputValue?: string
+  description?: ReactNode
+  errorMessage?: ReactNode | (ValidationResult) => ReactNode
+  id?: string
+  inputRef: RefObject<HTMLInputElement | null>
+  inputValue?: string
+  isDisabled?: boolean
+  isReadOnly?: boolean
+  label?: ReactNode
+  name?: string
+  onBlur?: (FocusEvent<HTMLInputElement>) => void
+  onFocus?: (FocusEvent<HTMLInputElement>) => void
+  onFocusChange?: (boolean) => void
+  onInputChange?: (string) => void
+  onKeyDown?: (KeyboardEvent) => void
+  onKeyUp?: (KeyboardEvent) => void
+  placeholder?: string
+}

/@react-aria/autocomplete:AutocompleteAria

+AutocompleteAria <T> {
+  descriptionProps: DOMAttributes
+  inputProps: InputHTMLAttributes<HTMLInputElement>
+  labelProps: DOMAttributes
+  menuProps: AriaMenuOptions<T>
+  register: ((KeyboardEvent) => string | null) => void
+}

@react-aria/collections

/@react-aria/collections:BaseCollection

 BaseCollection <T> {
   addNode: (CollectionNode<T>) => void
   at: () => Node<T>
   clone: () => this
   commit: (Key | null, Key | null, any) => void
+  filter: ((string) => boolean) => BaseCollection<T>
   getChildren: (Key) => Iterable<Node<T>>
   getFirstKey: () => void
   getItem: (Key) => Node<T> | null
   getKeyAfter: (Key) => void
   getKeys: () => void
   getLastKey: () => void
   removeNode: (Key) => void
   size: any
   undefined: () => void
 }

@react-aria/menu

/@react-aria/menu:AriaMenuOptions

 AriaMenuOptions <T> {
   aria-describedby?: string
   aria-details?: string
   aria-label?: string
   aria-labelledby?: string
   autoFocus?: boolean | FocusStrategy
   defaultSelectedKeys?: 'all' | Iterable<Key>
   disabledKeys?: Iterable<Key>
   disallowEmptySelection?: boolean
   id?: string
   isVirtualized?: boolean
   items?: Iterable<T>
   keyboardDelegate?: KeyboardDelegate
   onAction?: (Key) => void
   onClose?: () => void
+  onHoverStart?: (HoverEvent) => void
   onKeyDown?: (KeyboardEvent) => void
   onKeyUp?: (KeyboardEvent) => void
   onSelectionChange?: (Selection) => void
   selectedKeys?: 'all' | Iterable<Key>
   selectionMode?: SelectionMode
   shouldFocusWrap?: boolean
+  shouldUseVirtualFocus?: boolean
 }

/@react-aria/menu:getItemId

+getItemId <T> {
+  state: TreeState<T>
+  itemKey: Key
+  returnVal: undefined
+}

/@react-aria/menu:menuData

+menuData {
+  UNTYPED
+}

@react-stately/autocomplete

/@react-stately/autocomplete:useAutocompleteState

+useAutocompleteState {
+  props: AutocompleteStateOptions
+  returnVal: undefined
+}

/@react-stately/autocomplete:AutocompleteProps

+AutocompleteProps {
+  autoFocus?: boolean
+  defaultInputValue?: string
+  description?: ReactNode
+  errorMessage?: ReactNode | (ValidationResult) => ReactNode
+  inputValue?: string
+  isDisabled?: boolean
+  isReadOnly?: boolean
+  label?: ReactNode
+  onBlur?: (FocusEvent<HTMLInputElement>) => void
+  onFocus?: (FocusEvent<HTMLInputElement>) => void
+  onFocusChange?: (boolean) => void
+  onInputChange?: (string) => void
+  onKeyDown?: (KeyboardEvent) => void
+  onKeyUp?: (KeyboardEvent) => void
+  placeholder?: string
+}

/@react-stately/autocomplete:AutocompleteStateOptions

+AutocompleteStateOptions {
+  autoFocus?: boolean
+  defaultInputValue?: string
+  description?: ReactNode
+  errorMessage?: ReactNode | (ValidationResult) => ReactNode
+  inputValue?: string
+  isDisabled?: boolean
+  isReadOnly?: boolean
+  label?: ReactNode
+  onBlur?: (FocusEvent<HTMLInputElement>) => void
+  onFocus?: (FocusEvent<HTMLInputElement>) => void
+  onFocusChange?: (boolean) => void
+  onInputChange?: (string) => void
+  onKeyDown?: (KeyboardEvent) => void
+  onKeyUp?: (KeyboardEvent) => void
+  placeholder?: string
+}

/@react-stately/autocomplete:AutocompleteState

+AutocompleteState {
+  focusedNodeId: string | null
+  inputValue: string
+  setFocusedNodeId: (string | null) => void
+  setInputValue: (string) => void
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants