Search location filter duplicates selected locations when more than 1 location is selected
Closed this issue · 0 comments
tonyaellie commented
First Check
- This is not a feature request
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the documentation, with the integrated search.
- I already read the docs and didn't find an answer.
Homebox Version
v0.14.0
What is the issue you are experiencing?
The location filter duplicates all locations selected excluding the most recently selected one, ie: if you select bedrrom and then attic bedroom will show up twice in the list.
This issue seems to be caused by the fact that the unselected list in SearchFilter is comparing the object refrence:
const unselected = computed(() => {
return props.options.filter(o => {
if (searchFold.value.length > 0) {
return o[props.display].toLowerCase().includes(searchFold.value) && !selected.value.includes(o);
}
return !selected.value.includes(o);
});
});
This could be fixed by instead comparing a property on the object such as id:
const unselected = computed(() => {
return props.options.filter(o => {
if (searchFold.value.length > 0) {
return o[props.display].toLowerCase().includes(searchFold.value) && selected.value.every(s => s['id'] !== o['id']);
}
return selected.value.every(s => s['id'] !== o['id']);
});
});
Though as SearchFilter currently allows an array of anything to be passed if in the future a filter was added of which the items did not have an id this would cause issues, so it might be worth adding a prop to choose what property to filter by.
How can the maintainer reproduce the issue?
- Open the search page.
- Open the locations dropdown.
- Select at least two locations.
- See how the all but the most recently selected item show up multiple times in the list.
Deployment
Docker (Linux)
Deployment Details
No response