rob-balfre / svelte-select

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

select event sent when the value property is changed even when not slected through the UI component #436

Closed vboulaye closed 1 year ago

vboulaye commented 1 year ago

Hi,

I have an issue in the way I am using the svelte-select component: I have multiple Select in a form, whose backing data comes from a store than can be modified after the initial load(to refresh the data or change the object I want to edit) When this happens, the value of Select is modified by svelte, and this triggers the send of a select (which I use to trigger an update query call).

From what I understand this is due to those reactive statements in Select.svelte:

    $: {
        if (value) dispatchSelectedItem();
    }

    $: {
        if (!value && isMulti && prev_value) {
            dispatch('select', value);
        }
    }

I though of disabling my event handling when I know I am changing the data but is there a better way to make sure that the event when the data is changed in the UI only?

(and by the way thanks for the svelte-select component, it really helped me a lot!)

rob-balfre commented 1 year ago

@vboulaye v4 or v5 beta?

vboulaye commented 1 year ago

I am still using 4.4.7

I just tried with the 5.0.0-beta.16 and my problem seems to have disappeared

and I was not impacted by any breaking changes except styling but I have to check further.

thanks!