-
Notifications
You must be signed in to change notification settings - Fork 292
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
A11y/combobox nav refactor and expose list focus and keyboard navigation hook #636
Conversation
@@ -12,7 +12,7 @@ exports[`BreadcrumbsItem renders correctly when disabled item 1`] = ` | |||
<span | |||
aria-disabled="true" | |||
className="breadcrumb-content disabled" | |||
tabIndex="0" | |||
tabIndex="-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.
not relevant. for fixing tests.
…to a11y/combobox-nav � Conflicts: � src/components/Combobox/Combobox.jsx � src/components/Combobox/ComboboxHelpers/ComboboxHelpers.jsx � src/components/Combobox/components/ComboboxItems/ComboboxItems.jsx � src/components/Combobox/components/ComboboxOption/ComboboxOption.jsx
if (!onItemClick || !hasValidIndex || !isItemSelectable(itemIndex)) return; | ||
if (visualFocusItemIndex !== itemIndex) setVisualFocusItemIndex(itemIndex); | ||
onItemClick(event, itemIndex); | ||
triggerByKeyboard.current = event instanceof MouseEvent; |
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.
very nice!
src/hooks/useActiveDescendantListFocus/__tests__/useActiveDescendantListFocus.interactions.js
Outdated
Show resolved
Hide resolved
src/hooks/useActiveDescendantListFocus/__tests__/useActiveDescendantListFocus.interactions.js
Show resolved
Hide resolved
<UnstyledList> | ||
<UnstyledListItem>The component displays a list of values shown in one dimension - horizontal or vertical.</UnstyledListItem> | ||
<UnstyledListItem>The user can interact with the component items, and therefore, the component is focusable.</UnstyledListItem> | ||
<UnstyledListItem>When the user focuses on the component, the browser's real focus will always be on an element that is not one of the component's items. Most of the time, the focus will be on the component's Search item or different Text input item.</UnstyledListItem> |
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.
This is great, I think this single line represents what's the purpose of this hook in the best way
); | ||
}; | ||
|
||
UseActiveDescendantListFocus.propTypes = { |
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.
Is there any way to put the propTypes on the hook, and import them here to the story or something?
It feels like this file is "not important" (compared to the hook's main file), but it hides within it some valualble info about the hook itself
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.
We can think about standards regarding this subject but it will look weird
src/hooks/useActiveDescendantListFocus/__tests__/useActiveDescendantListFocus.jest.js
Outdated
Show resolved
Hide resolved
); | ||
} | ||
|
||
function runListUnitTest(isHorizontal) { |
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.
consider moving the code inside the describe
. maybe it's just me, but I found it confusing reading it
before reading describe
:)
…to a11y/combobox-nav
I did a refactor on the combobox keyboard navigation hook for more clear API and for fixing a11y issues inside the previous implementation.
I add a doc which explain when to use this hook and change the combobox code for using the new hook.
also add very basic happy flow interaction tests for the hook.
I would really like to check the on click functionality but I have problems with it. will be happy to explain.