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

fix: (WIP) Fix autocomplete searchfield focus ring #7626

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Jan 17, 2025

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 changed the base branch from main to autocomplete_focusvisible January 17, 2025 01:27
@@ -69,7 +69,8 @@ export const Group = /*#__PURE__*/ (forwardRef as forwardRefType)(function Group

let {hoverProps, isHovered} = useHover({onHoverStart, onHoverChange, onHoverEnd, isDisabled});
let {isFocused, isFocusVisible, focusProps} = useFocusRing({
within: true
within: true,
isTextInput: true
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 reason for the focus ring always reappearing as you type in the search field is because the Group itself has focusRing applied to it but doesn't have isTextInput. When useFocusVisible detects the native keyboards we dispatch on the autocomplete collection/collection items, it believes that it needs to update the modality for the Group. Normally this would be correct, however, the Group is still focused despite those events happening on different elements and thus its focus visibility get updated. Still trying to think of a good way to handle this

@rspbot
Copy link

rspbot commented Jan 17, 2025

@rspbot
Copy link

rspbot commented Jan 17, 2025

## API Changes

@react-aria/menu

/@react-aria/menu:MenuItemAria

 MenuItemAria {
   descriptionProps: DOMAttributes
   isDisabled: boolean
+  isFocusVisible: boolean
   isFocused: boolean
   isPressed: boolean
   isSelected: boolean
   keyboardShortcutProps: DOMAttributes
   menuItemProps: DOMAttributes
 }

@LFDanLu LFDanLu marked this pull request as ready for review January 17, 2025 21:25
@LFDanLu LFDanLu merged commit 5500dd7 into autocomplete_focusvisible Jan 17, 2025
3 of 17 checks passed
@LFDanLu LFDanLu deleted the fix_autocomplete_searchfield branch January 17, 2025 21:25
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