Closed cbetti closed 6 months ago
Any hints for a workaround? I didn't see a way to explicitly clear the Select.
It might be because you can't set justValue, it's a read-only prop. If you make a REPL I can show you an alternative.
On Fri, 8 Dec 2023 at 06:13, Chris Betti @.***> wrote:
After selecting an item, if the Select becomes disabled by a subsequent action, then the bound value is set to null or undefined while disabled, the selection remains. If enabled, the selection still remains, which does not correspond with the binding state.
<Select items={members} itemId="id" label="name" bind:justValue={$selectedId.value} on:clear={clearMemberSelection} disabled="{newMemberCheckboxState || nonMemberCheckboxState}" />
{$selectedId.value}
(in this case "selectedId" is a svelte-forms field, hence the $selectedId.value binding)
I did not test bind:value.
— Reply to this email directly, view it on GitHub https://github.com/rob-balfre/svelte-select/issues/653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUAM7SG4QTJD52SRRNJHPLYIIIMXAVCNFSM6AAAAABALR4AV6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZTCMZWHE4TKNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thank you, I think you're right and it's unrelated to disabled:
https://svelte.dev/repl/3ae71e0bfa23453da1b65f8b53ed0b8d?version=4.2.8
not familiar with the svelte-forms but hopefully enough in this example to unblock you...
https://svelte.dev/repl/21f1951476af401198324252007f6f60?version=4.2.8
On Fri, 8 Dec 2023 at 06:28, Chris Betti @.***> wrote:
Thank you, I think you're right and it's unrelated to disabled:
https://svelte.dev/repl/3ae71e0bfa23453da1b65f8b53ed0b8d?version=4.2.8
— Reply to this email directly, view it on GitHub https://github.com/rob-balfre/svelte-select/issues/653#issuecomment-1845975617, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUAM7RYQ6XUSMNSGYEC5LDYIIKHLAVCNFSM6AAAAABALR4AV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVHE3TKNRRG4 . You are receiving this because you commented.Message ID: @.***>
Really appreciate your help, I can definitely make it work using both bindings. Great component Rob!
After selecting an item, if the Select becomes disabled by a subsequent action, then something external sets the bound value to null or undefined while disabled, the prior Select selection remains. If enabled, the selection still remains, which does not correspond with the binding state.
I would expect the Select state to reflect the binding state both while disabled and when re-enabled, but at the very least when re-enabled.
(in this case "selectedId" is a svelte-forms field, hence the $selectedId.value binding)
I did not test bind:value.