simple-svelte-autocomplete icon indicating copy to clipboard operation
simple-svelte-autocomplete copied to clipboard

valueFieldName doesnt work

Open gponty opened this issue 1 year ago • 2 comments

Hi :)

<script>
	 import AutoComplete from "simple-svelte-autocomplete"
	
let selectedColor;
async function searchColor(keyword) {
  return [
		{ id:1,color:"White" },
		{ id:2,color:"Black" },
  ]
}
</script>

<AutoComplete
    searchFunction={searchColor}
    bind:selectedItem={selectedColor}
		labelFieldName="color"
		valueFieldName="id"
		onChange="{() => console.log(selectedColor)}"
/>

selectedColor = { id:1,color:"White" } instead of selectedColor = 1

REPL : https://svelte.dev/repl/b6a3421f9a574c148ba740d88e75ab81?version=4.2.9

Thank you

gponty avatar Jan 26 '24 15:01 gponty

Yes this is wrong in the readme I think, you should do bind:value={selectedColor} instead.

This example in the read me makes it look like you can use valueFieldName with selectedItem

Astronautilus14 avatar Feb 05 '24 22:02 Astronautilus14

Thank you @Astronautilus14

gponty avatar Feb 06 '24 10:02 gponty