svelecte
svelecte copied to clipboard
readSelection does not return whole object ?
Hi, the readSelection
seems to not return the whole passed object as is stated in the docs.
I have array of categories
[
{
"id": 2,
"name": "Kategorie A",
"multipleAllowed": false,
"children": [],
"parts": [],
"rootId": 1,
"rootName": "Čalounění",
"root": {
"id": 1,
"name": "Čalounění"
}
},
{
"id": 3,
"name": "Kategorie A",
"multipleAllowed": false,
"children": [],
"parts": [],
"rootId": 1,
"rootName": "Čalounění",
"root": {
"id": 1,
"name": "Čalounění"
}
}
]
setup as this
<Svelecte
searchable={false}
options={category.children}
inputId="sp-cat-{category.id}"
bind:readSelection={selectedCategory}
bind:value={selectedCategoryId}
on:change={handleCategorySelect}
placeholder="Vyberte kategorii"
/>
Sometimes the read selection returns just a option like object
{
"id": 2,
"name": "Kategorie A"
}
instead of a whole thing
Am I missing something ?
This happens only the second time the svelecte component is initialized/updated. I did check the passed options prop and it's fine
Are you using the latest version? If yes, can you setup reproducible example in REPL? It works fine for me when I am trying this.
Can you at least share how your svelecte markup looks like?
On 1. 6. 2022 14:53, tom-acceleratecompliance wrote:
Hi, I'll also try to bring together a reproduction case for this. It is always occurring to one of my dropdown, and never to another, even though they seem to be effectively identical.
I have three keys in my object, |id|, |name| and |email| and ID is always dropped from |readSelection| or |value| when in |valueAsObject| mode.
I have rewrote the logic so that I don't use readSelection
at all, since I had to finish my project. This can be probably closed... The behavior is weird and hard to isolate.
Apologies for my message @mskocik - the issue was found upstream of the component through a series of binds.
@tom-acceleratecompliance thanks for clarifying your case.
Anyway I will keep this open as potential bug.
Most probably fixed in v4, which has just been released. Re-open if you would know how to reproduce it