-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(Dropdown): handle keyboard events for arrows, space and enter keys locally #4004
Conversation
size-limit report
|
Codecov Report
@@ Coverage Diff @@
## master #4004 +/- ##
=======================================
Coverage 99.84% 99.84%
=======================================
Files 184 184
Lines 3220 3233 +13
=======================================
+ Hits 3215 3228 +13
Misses 5 5
Continue to review full report at Codecov.
|
@@ -8,7 +8,7 @@ const options = [ | |||
] | |||
|
|||
const DropdownExampleDisabledItem = () => ( | |||
<Dropdown text='Dropdown' options={options} open /> | |||
<Dropdown text='Dropdown' options={options} /> |
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 Dropdown
should not be be opened by default,
@@ -52,28 +52,17 @@ export default class Dropdown extends Component { | |||
|
|||
static getAutoControlledStateFromProps(nextProps, computedState, prevState) { | |||
// These values are stored only for a comparison on next getAutoControlledStateFromProps() | |||
const derivedState = { __value: nextProps.value, __options: nextProps.options } | |||
const derivedState = { __options: nextProps.options, __value: computedState.value } |
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 should use computedState.value
as we want to compute new selectedIndex
based the component's state
Fixes #3994.
This PR is focused on the single thing to move event handling from
document
(i.e.EventStack
) toDropdown
s scope as it creates various issues when multipleDropdown
are opened. And there are no reasons to have these listeners globally.