rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.25k stars 175 forks source link

In "multiple" mode, seems like event propagation is bugging out. Clicking on X to remove a tag opens the list #554

Closed 0radek closed 1 year ago

0radek commented 1 year ago

First off, thanks for this awesome library. I'm working on a MVP and this has saved me a few days of work.

I have a minor issue, and I tried messing around in the code a bit and added some stopPropagations, but was unable to resolve the issue locally. Maybe you know a simple way to fix it but whenever this click occurs https://github.com/rob-balfre/svelte-select/blob/master/src/lib/Select.svelte#L761 the dropdown list opens.

My opinion is that the dropdown list should appear when the parent container is clicked. If the tag or its X is clicked, it should not open the dropdown list. Or, maybe there could be some precedence option to toggle based on needs?

The reason I bring this up is that when you click the X and the list opens, clicking another X on another tag closes the list. Then clicking the X on another tag opens. So, it is kind of jarring so maybe the former behavior I posted above is preferable?

This behavior with the dropdown list appearing when clicking the X can be seen here: https://svelte-select-examples.vercel.app/examples/advanced/create-item-multiple

Add a couple items, and click the X.

Thoughts?

rob-balfre commented 1 year ago

@0radek looks like if you remove the final item of selected items its ok but if you remove anything else it opens. That's a bug in my opinion.

I'm actually working on a new prop to give more granular control of listOpen, not quite figured out the best approach but I'll include a bug fix for this either way.

Thanks for reporting.

0radek commented 1 year ago

thanks @rob-balfre !

rob-balfre commented 1 year ago

@0radek fixed the bug... https://svelte-select-git-develop-robertbalfre.vercel.app/examples/advanced/create-item-multiple Also added a new prop closeListOnChange

v 5.3.0-beta.7

How's that looking?

0radek commented 1 year ago

@rob-balfre that's amazing, thanks so much! works great

rob-balfre commented 1 year ago

Released 5.3.0