iron-menu-behavior icon indicating copy to clipboard operation
iron-menu-behavior copied to clipboard

Feature Request: Opt out of focus() on _focusedItemChanged

Open jpodwys opened this issue 7 years ago • 2 comments

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

demo

Steps to reproduce

  1. Drop this element onto a page
  2. Wire it up to set its options property when a user types (preferably with a slight delay simulating a network call)
  3. Enable IME for Chinese
  4. Type "1990n" into the input in such a way that this line of code executes after typing the "n"
  5. 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)

jpodwys avatar Oct 27 '17 18:10 jpodwys

Let's celebrate the one month anniversary of this issue/pr combo by merging my PR! What do ya say?

@bicknellr @notwaldorf @cdata @rictic

jpodwys avatar Nov 27 '17 17:11 jpodwys

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.

bicknellr avatar Nov 27 '17 23:11 bicknellr