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 keys to open menu #32750

Merged
merged 10 commits into from
Feb 3, 2021

Conversation

sijusamson
Copy link
Contributor

Fixes #32714.

@sijusamson sijusamson requested a review from a team as a code owner January 10, 2021 14:01
@sijusamson sijusamson force-pushed the dropdown_keys_no_longer_open_menu branch from 0ebc541 to 3bc08de Compare January 10, 2021 14:17
@XhmikosR XhmikosR changed the title Dropdown keys no longer open menu Fix dropdown keys to open menu Jan 13, 2021
@XhmikosR
Copy link
Member

Can you add a test please? This wasn't caught.

@sijusamson sijusamson force-pushed the dropdown_keys_no_longer_open_menu branch from 3bc08de to b2c710b Compare January 17, 2021 04:42
@sijusamson
Copy link
Contributor Author

Can you add a test please? This wasn't caught.

Done !

@XhmikosR
Copy link
Member

Works good, thanks!

@patrickhlauke anything a11y-wise we might be missing?
@rohit2sharma95: LGTY?

@patrickhlauke
Copy link
Member

It's more a nice to have than a necessary (from a11y point of view) feature, but conversely it's not introducing any issues either. Long way of saying LGTM.

js/tests/unit/dropdown.spec.js Show resolved Hide resolved
Comment on lines +453 to +478
if (!isActive && (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY)) {
const button = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0]
button.click()
return
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Now the method dataApiKeydownHandler has a linting warning:
Static method 'dataApiKeydownHandler' has a complexity of 23. Maximum allowed is 20.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rohit2sharma95 Thank you for your suggestion, let me try to figure out the best possible solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per my findings, this linting warning can be removed if we split the function dataApiKeydownHandler. We can create a new static method, and pass on some functionality there.
But should we do that ?
@rohit2sharma95 @patrickhlauke @XhmikosR

Copy link
Member

Choose a reason for hiding this comment

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

I'd say ignore it for now and tackle it later in another PR.

@XhmikosR XhmikosR marked this pull request as draft January 28, 2021 21:27
@sijusamson sijusamson force-pushed the dropdown_keys_no_longer_open_menu branch from e0b1cc7 to 767c4be Compare January 31, 2021 07:12
@sijusamson sijusamson marked this pull request as ready for review January 31, 2021 07:21
@sijusamson sijusamson force-pushed the dropdown_keys_no_longer_open_menu branch from 767c4be to 7927a8f Compare January 31, 2021 07:45
@XhmikosR
Copy link
Member

XhmikosR commented Feb 1, 2021

BTW does it make sense to open the dropdown but not select the first/last element depending on the arrow key?

I feel like it's an extra key. But that's for later too. :)

@XhmikosR XhmikosR merged commit b376a3d into twbs:main Feb 3, 2021
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.

Dropdown up/down keys no longer open menu
4 participants