-
Notifications
You must be signed in to change notification settings - Fork 934
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(highlightedIndex): do not highlight disabled items by keyboard #799
Conversation
How can we progress this PR? Would it be possible to merge this PR with the logic for vanilla downshift and have the useSelect scenarios as enhancement? |
b6325b4
to
acd2427
Compare
Codecov Report
@@ Coverage Diff @@
## master #799 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 12
Lines 886 923 +37
Branches 184 190 +6
=====================================
+ Hits 886 923 +37
Continue to review full report at Codecov.
|
@weyert we should be close with this. I only need to add tests to the hooks and finish the PR description. |
Which tests need to be added? Looks like it already has 100% coverage? |
I was not 100% confident even with that coverage so added separate tests for the index generating function. Now it's better. |
Amazing, thanks @silviuavram :D |
🎉 This PR is included in version 4.0.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Awesome! Thank you, excited about this 😀 |
@all-contributors please add @jgodi for code |
@silviuavram I've put up a pull request to add @jgodi! 🎉 |
What:
Allows disabled items to be skipped by keyboard highlight (arrow keys, home, end, character keys).
Why:
To have this scenario properly working.
How:
Refactored the utils methods that handle the index generation logic for highlighting. These methods also request
getItemNodeFromIndex
that will tell them if the item is marked as disabled or not.This method comes from the hooks / component and is sent as parameter to the utils functions.
Test cases:
find next non-disabled if next is disabled on arrow down.
find prev non-disabled if prev is disabled on arrow up.
if not circular and no non-disabled item can be highlighted, index should stay the same.
if circular, the search for non-disabled item is resumed from first / last item.
on home/end, if first/last are disabled, then start searching downwards/upwards for first non-disabled.
on character key (useSelect) it will not highlight if item is disabled, it will search instead for the next item that starts with the key(s) and is not disabled.
Additional changes:
useSelect
hasfalse
default prop forcircularNavigation
, whileuseCombobox
has it `true.<Downshift>
.useCombobox
now works properly withinitialHighlightedIndex
anddefaultHighlightedIndex
.getNextWrappingIndex
andgetItemIndexByCharacterKey
Checklist:
Started to work based on #752
Closes #728 #825