Fix 7 GUIs crud example for delete when filtered

This example could delete the incorrect person when a filter was applied. Just an example, but the behavior was confusing when I played with it, so I thought it worth fixing.
pull/3021/head
Jacob Wright 5 years ago committed by Conv
parent 32107d8102
commit 52b5e05ead

@ -43,10 +43,12 @@
}
function remove() {
people = [...people.slice(0, i), ...people.slice(i + 1)];
// Remove selected person from the source array (people), not the filtered array
const index = people.indexOf(selected);
people = [...people.slice(0, index), ...people.slice(index + 1)];
first = last = '';
i = Math.min(i, people.length - 1);
i = Math.min(i, filteredPeople.length - 2);
}
function reset_inputs(person) {

Loading…
Cancel
Save