Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix dropdown escape propagation#33479

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

alpadev
Copy link
Contributor

@alpadevalpadev commentedMar 25, 2021
edited
Loading

Closes#33465

@alpadevalpadev requested a review froma team as acode ownerMarch 25, 2021 17:36
@GeoSot
Copy link
Member

LGTM

Copy link
Contributor

@rohit2sharma95rohit2sharma95 left a comment

Choose a reason for hiding this comment

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

if(!isActive||event.key===SPACE_KEY){
Dropdown.clearMenus()
return
}

This should not be changed as below? 🤔

if(isActive&&event.key===SPACE_KEY){Dropdown.clearMenus()return}

@alpadev
Copy link
ContributorAuthor

alpadev commentedMar 30, 2021
edited
Loading

if(!isActive||event.key===SPACE_KEY){
Dropdown.clearMenus()
return
}

This should not be changed as below? 🤔

if(isActive&&event.key===SPACE_KEY){Dropdown.clearMenus()return}

@rohit2sharma95 Not sure if this is even needed.

This checks for keys that are dropdown commands.

if(/input|textarea/i.test(event.target.tagName) ?
event.key===SPACE_KEY||(event.key!==ESCAPE_KEY&&
((event.key!==ARROW_DOWN_KEY&&event.key!==ARROW_UP_KEY)||
event.target.closest(SELECTOR_MENU))) :
!REGEXP_KEYDOWN.test(event.key)){
return
}

But the regex is missing the space key so I'm not sure if we even reach this block.

constREGEXP_KEYDOWN=newRegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY}`)

@rohit2sharma95
Copy link
Contributor

rohit2sharma95 commentedMar 30, 2021
edited
Loading

This change was made in#29885 (and then in#30597, that's unrelated though). Anything related to input groups?

/CC@MartijnCuppens

@rohit2sharma95
Copy link
Contributor

And can not theselectMenuItem method be a private method instead of a static one (as it is not being used directly 🤔)? It can be used through the context of the dropdown then IMO. Because thedataApiKeydownHandler method is bound with the dropdown elements only (menu and the toggle button).

@alpadev
Copy link
ContributorAuthor

alpadev commentedMar 30, 2021
edited
Loading

And can not theselectMenuItem method be a private method instead of a static one (as it is not being used directly 🤔)? It can be used through the context of the dropdown then IMO. Because thedataApiKeydownHandler method is bound with the dropdown elements only (menu and the toggle button).

I didn't mean to refactor too much in the scope of this issue but rather to just get rid of that Eslint warning. I agree that using a static method isn't ideal but the item selection functionality wasn't bound to the instance before and I made it the waydataApiKeydownHandler was implemented.

If you want me to change it I should be able to do this tho.

@GeoSotGeoSotforce-pushed thefix-dropdown-escape-propagation branch fromc019d3d to3f658e5CompareMarch 30, 2021 22:48
@GeoSot
Copy link
Member

Till now is just a refactoring that I can follow, a minor fix and a valid test that succeeds . Sotill here I find itOK.

I agree to refactorselectMenuItem to private method, and would also love to seedataApiKeydownHandler gordian knot untied, but on another PR, to avoid mistakes

So if we can all agree on these, I would prefer to keep it as it is and if@alpadev has the courage to keep up with a following PR

alpadev and rohit2sharma95 reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@GeoSotGeoSotGeoSot approved these changes

+1 more reviewer

@rohit2sharma95rohit2sharma95rohit2sharma95 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

v5: Dropdown trigger button "swallows" Esc keypresses when focused

4 participants

@alpadev@GeoSot@rohit2sharma95@XhmikosR

[8]ページ先頭

©2009-2025 Movatter.jp