Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyed each has duplicated key in realtime data context #204

Open
PlusA2M opened this issue May 17, 2023 · 0 comments
Open

Keyed each has duplicated key in realtime data context #204

PlusA2M opened this issue May 17, 2023 · 0 comments

Comments

@PlusA2M
Copy link

PlusA2M commented May 17, 2023

I've experiencing issue Error: Cannot have duplicate keys in a keyed each in the situation that the data for the search function will be update after user's interaction.

Search function

function searchFromData(keyword: string) {
    return data.filter((m) => m.phone?.includes(keyword)) // return { id: string, phone: string}
}

Key attribute settings

labelFieldName="phone"
keywordsFieldName="phone"
valueFieldName="id"
sortByMatchedKeywords="true"

Hotfix on SimpleAutoComplete.svelte

Not knowing the whole lifecycle of the simple-svelte-autocomplete, I've added the timestamp to avoid that as a temporary hot fix.

{@const now = Date.now()}
      {#each selectedItem as tagItem, i (`${valueFunction(tagItem, true)}-${now}`)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant