iron-menu-behavior
iron-menu-behavior copied to clipboard
Feature Request: Opt out of focus() on _focusedItemChanged
Description
Currently, calling paper-listbox.select(n);
causes the referenced list item to receive focus. This is problematic when users are typing with IME because stealing focus from the input that triggers the OS-level IME popup causes that popup to disappear.
More Info
I have a date/location picker typeahead. When the user types into the input, I open a paper-listbox
instance and programmatically select the first item for them. Because doing so steals focus, I then immediately replace focus to the input. However, blurring the input causes IME tools to disappear.
Expected outcome
I would like to have an opt-in way to prevent focus of the selected list item, perhaps via a property named preventFocusOnItemChanged
or something similar. I'd like for the desired item to be highlighted, but not focused. I've put together #97 (which has a diff of only 9 lines added) to accomplish this.
Live Demo
Steps to reproduce
- Drop this element onto a page
- Wire it up to set its
options
property when a user types (preferably with a slight delay simulating a network call) - Enable IME for Chinese
- Type "1990n" into the input in such a way that this line of code executes after typing the "n"
- Notice that
iron-menu-behavior
blurs the input causing the IME menu to disappear as seen in the gif above
Browsers Affected
- [x] Chrome
- [x] Firefox (Did not test others)
Let's celebrate the one month anniversary of this issue/pr combo by merging my PR! What do ya say?
@bicknellr @notwaldorf @cdata @rictic
Hi @jpodwys, have you considered listening for the down key and setting the selected item to the first when the user pushes that? I think that's the typical way to handle this scenario if this is a generic input field with suggested options. I think you can also set .selected
directly to avoid the focusing behavior.