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: add isFocusVisible useMenuItem and fix focusRing when typing in Autocomplete SearchField #7625

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/@react-aria/menu/src/useMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface MenuItemAria {

/** Whether the item is currently focused. */
isFocused: boolean,
/** Whether the item is keyboard focused. */
isFocusVisible: boolean,
/** Whether the item is currently selected. */
isSelected: boolean,
/** Whether the item is currently in a pressed state. */
Expand Down Expand Up @@ -316,6 +318,7 @@ export function useMenuItem<T>(props: AriaMenuItemProps, state: TreeState<T>, re
id: keyboardId
},
isFocused,
isFocusVisible: isFocused && isFocusVisible(),
isSelected,
isPressed,
isDisabled
Expand Down
7 changes: 3 additions & 4 deletions packages/react-aria-components/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI
selectionManager
}, state, ref);

let {isFocusVisible, focusProps} = useFocusRing();
snowystinger marked this conversation as resolved.
Show resolved Hide resolved
let {hoverProps, isHovered} = useHover({
isDisabled: states.isDisabled
});
Expand All @@ -355,7 +354,7 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI
values: {
...states,
isHovered,
isFocusVisible,
isFocusVisible: states.isFocusVisible,
selectionMode: selectionManager.selectionMode,
selectionBehavior: selectionManager.selectionBehavior,
hasSubmenu: !!props['aria-haspopup'],
Expand All @@ -367,13 +366,13 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI

return (
<ElementType
{...mergeProps(menuItemProps, focusProps, hoverProps)}
{...mergeProps(menuItemProps, hoverProps)}
{...renderProps}
ref={ref}
data-disabled={states.isDisabled || undefined}
data-hovered={isHovered || undefined}
data-focused={states.isFocused || undefined}
data-focus-visible={isFocusVisible || undefined}
data-focus-visible={states.isFocusVisible || undefined}
data-pressed={states.isPressed || undefined}
data-selected={states.isSelected || undefined}
data-selection-mode={selectionManager.selectionMode === 'none' ? undefined : selectionManager.selectionMode}
Expand Down
Loading