-
Notifications
You must be signed in to change notification settings - Fork 933
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
feat(hooks): add useSelect hook #747
Conversation
Codecov Report
@@ Coverage Diff @@
## master #747 +/- ##
======================================
Coverage 100% 100%
======================================
Files 3 9 +6
Lines 418 694 +276
Branches 105 153 +48
======================================
+ Hits 418 694 +276
Continue to review full report at Codecov.
|
🎉 This PR is included in version 3.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@@ -8,6 +8,18 @@ config.plugins[cjsPluginIndex] = commonjs({ | |||
include: 'node_modules/**', | |||
namedExports: { | |||
'react-is': ['isForwardRef'], | |||
react: ['useReducer', 'useEffect', 'useRef', 'useState'], | |||
'node_modules/keyboard-key/src/keyboardKey.js': ['getKey'], |
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.
Why was this added? Wouldn't this require all rollup clients to include this?
} | ||
|
||
export interface UseSelectProps<Item> { | ||
items: Item[] |
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.
I think this could actually be readonly Item[]
(or ReadonlyArray<Item>
which is equivalent) as Downshift doesn't mutate this array, right? What do you think about changing it?
Adding
useSelect
, the first hook ofDownshift
.Downshift
is often used to create custom<select>
widgets. Even if it's designed as an autocomplete solution first, it proves it's a versatile component and we should aim to keep it this way.As a follow-up to #683 I started the change to the hooks-based API by writing
useSelect
.It aims to provide the same functionality and accessibility as a native HTML
<select>
. It should follow the ARIA Dropdown Pattern for consistency reasons (it should work on Windows/Mac, with Jaws/NVDA/VoiceOver/ChromeVox no matter if the browser is Chrome/Safari/Firefox/Edge/IE).The API is meant to resemble Downshift's.
Functionality provided out of the box:
aria
attributes on both these elements, widget should be accessible via all screen readers.aria-live
message on menu open and item select.