From 5e4246e85ee57125d4bd29041763f8f6c8320bbe Mon Sep 17 00:00:00 2001 From: Shunichi Hato Date: Sun, 3 Nov 2019 13:58:35 +0900 Subject: [PATCH] Make selection reactive with search --- site/content/examples/20-7guis/05-7guis-crud/App.svelte | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/site/content/examples/20-7guis/05-7guis-crud/App.svelte b/site/content/examples/20-7guis/05-7guis-crud/App.svelte index 68574bca43..67145ceec7 100644 --- a/site/content/examples/20-7guis/05-7guis-crud/App.svelte +++ b/site/content/examples/20-7guis/05-7guis-crud/App.svelte @@ -28,6 +28,11 @@ }) : people.map(person => Object({ matched: true, person: person })); + $: if (!filteredPeople[i].matched) { + let newIndex = filteredPeople.findIndex(person => person.matched); + if (newIndex >= 0) i = newIndex; + } + $: selected = filteredPeople[i].person; $: reset_inputs(selected);