mirror of https://github.com/stashapp/stash.git
Fix duplicate items appearing in selected list (again) (#5377)
* Fix duplicate detection in useListSelect * Prevent double invocation of select handler
This commit is contained in:
parent
32c48443b5
commit
5283eb8ce3
|
@ -229,13 +229,13 @@ export function useListSelect<T extends { id: string }>(items: T[]) {
|
|||
function singleSelect(id: string, selected: boolean) {
|
||||
setLastClickedId(id);
|
||||
|
||||
// prevent duplicates
|
||||
if (selected && selectedIds.has(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setItemsSelected((prevSelected) => {
|
||||
if (selected) {
|
||||
// prevent duplicates
|
||||
if (prevSelected.some((v) => v.id === id)) {
|
||||
return prevSelected;
|
||||
}
|
||||
|
||||
const item = items.find((i) => i.id === id);
|
||||
if (item) {
|
||||
return [...prevSelected, item];
|
||||
|
|
|
@ -154,6 +154,7 @@ export const GridCard: React.FC<ICardProps> = (props: ICardProps) => {
|
|||
if (props.selecting) {
|
||||
props.onSelectedChanged(!props.selected, shiftKey);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue