Blueprint: MultiSelect tagInputProps: How to avoid input focus when onRemove triggered?

Created on 22 Jan 2019  路  7Comments  路  Source: palantir/blueprint

Environment

  • __Package version(s)__: 2
  • __Browser and OS versions__:

Question

Is it possible to prevent input focus when onRemove triggered? Thanks in advance!

P3 select enhancement help wanted

Most helpful comment

I think what MichaelLonin is maybe getting at here is that there seems to be no way currently to stop the select popover from opening when the tag X is clicked:

clickingRemoveOpensPopup

I definitely think that functionality should be optional. Unfortunately the onRemove handler signature looks like this:

handleTagRemove = (string, index) => {...}

So we can't manually stop event propagation/prevent default ourselves.

Thoughts @giladgray @adidahiya ?

All 7 comments

I think what MichaelLonin is maybe getting at here is that there seems to be no way currently to stop the select popover from opening when the tag X is clicked:

clickingRemoveOpensPopup

I definitely think that functionality should be optional. Unfortunately the onRemove handler signature looks like this:

handleTagRemove = (string, index) => {...}

So we can't manually stop event propagation/prevent default ourselves.

Thoughts @giladgray @adidahiya ?

Removing the tags should not open the popover. The intent is not to select new options when removing.

@adidahiya I can think of two ways of fixing this:

  1. Always stopping the on click event propagation when a tag is removed
  2. Passing the original click event as an extra argument to handleTagRemove and letting consumers stop propagation if required.

I'm more than happy to implement any of those solutions, or any other solution that you may suggest.

@adidahiya ok I implemented solution 1 since it's the most straight forward and doesn't require API changes. Please take a look and let me know if you want any changes.

_Moving my comments from #4034 here, this might be the right place to continue the conversation_

@adidahiya what about this?

Another approach would be to pass the event to consumers of TagInput

Something else we could try is handling the event propagation in MultiSelect, and assuming we can know the identity of the event target, ignore click events originating from removing a tag. Not sure if that's even possible, but I'm happy to explore that path.

What do you think?

@grancalavera I would still like to avoid "ignoring" clicks or stopping event propagation. Can you implement a new prop on TagInput which prevents the input from getting focus on tag remove (and enable that prop by default in MultiSelect)? I haven't looked into it deeply but there seems to be a fair amount of focus management in that component which could be tweaked.

Cool, I'll start looking into it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

havesomeleeway picture havesomeleeway  路  3Comments

giladgray picture giladgray  路  3Comments

raiju picture raiju  路  3Comments

vilav picture vilav  路  3Comments

Goddak picture Goddak  路  3Comments