Closed EskelCz closed 1 year ago
Not internally but there are a few ways to achieve the same result with reactive statements. How do you want it to work? Lock more selections when limit is reached?
On Tue, 1 Nov 2022, 11:50 am David Spohr, @.***> wrote:
Is there a way to set the maximum number of selected items? Thanks.
— Reply to this email directly, view it on GitHub https://github.com/rob-balfre/svelte-select/issues/490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUAM7VZZIAJLSRQSRO7BZDWGBSMHANCNFSM6AAAAAARTTFDXY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@rob-balfre Exactly, disabling the ability to select more than the limit, until some are deselected again. Maybe also triggering an event, so that I can hook up some explanation (alert, label, shaking animation, etc.) to the user.
In my case it's just a prevention of abuse, if someone tries to select hundreds of items just to see what happens. Don't want to even test that scenario. :)
V5?
Yep
@EskelCz here's one way of doing it... prob a few other ways too.
https://svelte-select-examples.vercel.app/examples/advanced/limit-multi-value
I'd prefer an integrated feature, for the sake of clean code, but this does the trick for now. Thanks a lot
Is there a way to limit the number of selected items? Thanks.