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

fix(Dropdown): handle keyboard events for arrows, space and enter keys locally #4004

Merged
merged 4 commits into from
Jul 29, 2020

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Jul 29, 2020

Fixes #3994.


This PR is focused on the single thing to move event handling from document (i.e. EventStack) to Dropdowns scope as it creates various issues when multiple Dropdown are opened. And there are no reasons to have these listeners globally.

@github-actions
Copy link

size-limit report

Path Size
bundle-size/dist/Button.size.js 70.84 KB (0%)
bundle-size/dist/Icon.size.js 33.41 KB (0%)
bundle-size/dist/Image.size.js 66.13 KB (0%)
bundle-size/dist/Portal.size.js 49.9 KB (0%)

@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2020

Codecov Report

Merging #4004 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4004   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files         184      184           
  Lines        3220     3233   +13     
=======================================
+ Hits         3215     3228   +13     
  Misses          5        5           
Impacted Files Coverage Δ
src/modules/Dropdown/Dropdown.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ecf576...b61bcfb. Read the comment docs.

@@ -8,7 +8,7 @@ const options = [
]

const DropdownExampleDisabledItem = () => (
<Dropdown text='Dropdown' options={options} open />
<Dropdown text='Dropdown' options={options} />
Copy link
Member Author

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,

@vercel vercel bot temporarily deployed to Preview July 29, 2020 12:01 Inactive
@@ -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 }
Copy link
Member Author

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

@layershifter layershifter merged commit 28eee26 into master Jul 29, 2020
@layershifter layershifter deleted the fix/dropdown-space branch July 29, 2020 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dropdown: allowAdditions with Space key does not work
2 participants