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

[list-box] Reset the focused item when connected (or disconnected) from the DOM #924

Open
jouni opened this issue Feb 14, 2018 · 2 comments

Comments

@jouni
Copy link
Member

jouni commented Feb 14, 2018

When the list box is connected to the DOM, we should reset the focused item either to the first selected item or, if there is no selected item, to the first item in the list.

This would at least help when used inside vaadin-context-menu, where the common case is that when the menu opens the focus should be on the first item in the menu.

@platosha
Copy link
Contributor

Note that resetting focus on when connected might break overlays with list box inside, e. g., the dropdown menu.

Removing focus indication when disconnected should be fine, since naturally disconnected elements loose focus anyway.

@jouni
Copy link
Member Author

jouni commented Feb 20, 2018

Why would it break?

I’m not talking about removing focus indication, though. I’m talking about changing which item has the focus indication and keyboard focus when the list-box becomes visible.

Maybe we should even switch the focus back to the first (selected) item when the list-box itself loses focus? Is there a benefit of letting the user return to the previous item they had keyboard focus on? It’s not visible at least, so it can be a bit arbitrary for the user where the keyboard focus lands in a longer list. Could be more expected that it always lands on the first (selected) item.

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-list-box May 19, 2021
@web-padawan web-padawan changed the title Reset the focused item when connected (or disconnected) from the DOM [list-box] Reset the focused item when connected (or disconnected) from the DOM May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
vaadin-core
  
📬  Inbox
Development

No branches or pull requests

3 participants