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

How to unfocus the Select component after selecting an item? #11690

Closed
ghost opened this issue Jun 2, 2018 · 3 comments
Closed

How to unfocus the Select component after selecting an item? #11690

ghost opened this issue Jun 2, 2018 · 3 comments
Labels
component: select This is the name of the generic UI component, not the React module!

Comments

@ghost
Copy link

ghost commented Jun 2, 2018

I'd like to know how I can unfocus the select component that is showcased [here][1] after making a selection. After selecting an item the input label is active as well as the button in the background and I'd like to automatically unfocus it after making a selection. You can see this behaviour in this gif:

2018-06-03_01-29-58

@ghost
Copy link
Author

ghost commented Jun 3, 2018

To my surprise I was able to achieve the desired behaviour. I have added MenuProps={{ onExited: this.onExitedRegionSelect }} to my <Select /> with the following method:

private onExitedRegionSelect(node: HTMLElement): void {
    // At this point it can only be a child of the Select root
    (document.activeElement as HTMLElement).blur();
}

@ghost ghost closed this as completed Jun 3, 2018
@billsaysthis
Copy link

Thank you @nearautomata !!

@borm
Copy link

borm commented Sep 30, 2018

up, the onExited method has some delay

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 20, 2022
@zannager zannager added component: select This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 9, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

4 participants