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

A11y/combobox nav refactor and expose list focus and keyboard navigation hook #636

Merged
merged 21 commits into from
Apr 28, 2022

Conversation

hadasfa
Copy link
Contributor

@hadasfa hadasfa commented Apr 14, 2022

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.

@hadasfa hadasfa changed the title A11y/combobox nav refactor and expose navigation hook A11y/combobox nav refactor and expose list focus and keyboard navigation hook Apr 14, 2022
@@ -12,7 +12,7 @@ exports[`BreadcrumbsItem renders correctly when disabled item 1`] = `
<span
aria-disabled="true"
className="breadcrumb-content disabled"
tabIndex="0"
tabIndex="-1"
Copy link
Contributor Author

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.

@hadasfa hadasfa requested a review from laviomri April 20, 2022 10:47
Hadas Farhi added 3 commits April 20, 2022 13:48
…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;
Copy link
Contributor

Choose a reason for hiding this comment

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

very nice!

<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>
Copy link
Contributor

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 = {
Copy link
Contributor

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

Copy link
Contributor Author

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

webpack/published-components.js Show resolved Hide resolved
src/components/Combobox/__tests__/combobox-tests.jest.js Outdated Show resolved Hide resolved
@hadasfa hadasfa requested a review from MosheZemah April 24, 2022 21:00
);
}

function runListUnitTest(isHorizontal) {
Copy link
Contributor

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

@hadasfa hadasfa removed the request for review from MosheZemah April 25, 2022 10:29
@hadasfa hadasfa merged commit d02f3ba into master Apr 28, 2022
@hadasfa hadasfa deleted the a11y/combobox-nav branch April 28, 2022 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants