diff --git a/components/InputSelect/CollectionSelection.tsx b/components/InputSelect/CollectionSelection.tsx index 0d98bd65..cac9c46b 100644 --- a/components/InputSelect/CollectionSelection.tsx +++ b/components/InputSelect/CollectionSelection.tsx @@ -7,15 +7,16 @@ import CreatableSelect from "react-select/creatable"; type Props = { onChange: any; + showDefaultValue?: boolean; defaultValue?: - | { - label: string; - value?: number; - } - | undefined; + | { + label: string; + value?: number; + } + | undefined; }; -export default function CollectionSelection({ onChange, defaultValue }: Props) { +export default function CollectionSelection({ onChange, defaultValue, showDefaultValue = true }: Props) { const { collections } = useCollectionStore(); const router = useRouter(); @@ -50,8 +51,8 @@ export default function CollectionSelection({ onChange, defaultValue }: Props) { onChange={onChange} options={options} styles={styles} - defaultValue={defaultValue} - // menuPosition="fixed" + defaultValue={showDefaultValue ? defaultValue : null} + // menuPosition="fixed" /> ); } diff --git a/components/LinkViews/LinkList.tsx b/components/LinkViews/LinkList.tsx index 78f5cb78..df899def 100644 --- a/components/LinkViews/LinkList.tsx +++ b/components/LinkViews/LinkList.tsx @@ -35,11 +35,13 @@ export default function LinkCardCompact({ const { account } = useAccountStore(); const { links, setSelectedLinks, selectedLinks } = useLinkStore(); - const handleCheckboxClick = ( - link: LinkIncludingShortenedCollectionAndTags - ) => { - if (selectedLinks.includes(link)) { - setSelectedLinks(selectedLinks.filter((e) => e !== link)); + const handleCheckboxClick = (link: LinkIncludingShortenedCollectionAndTags) => { + const linkIndex = selectedLinks.findIndex(selectedLink => selectedLink.id === link.id); + + if (linkIndex !== -1) { + const updatedLinks = [...selectedLinks]; + updatedLinks.splice(linkIndex, 1); + setSelectedLinks(updatedLinks); } else { setSelectedLinks([...selectedLinks, link]); } @@ -85,7 +87,7 @@ export default function LinkCardCompact({ selectedLink.id === link.id)} onChange={() => handleCheckboxClick(link)} /> )} diff --git a/components/ModalContent/BulkEditLinksModal.tsx b/components/ModalContent/BulkEditLinksModal.tsx index c161f93e..f274f736 100644 --- a/components/ModalContent/BulkEditLinksModal.tsx +++ b/components/ModalContent/BulkEditLinksModal.tsx @@ -57,7 +57,7 @@ export default function BulkEditLinksModal({ onClose }: Props) {

Collection

- +
diff --git a/hooks/useLinks.tsx b/hooks/useLinks.tsx index 77e4dce7..fde8bbb5 100644 --- a/hooks/useLinks.tsx +++ b/hooks/useLinks.tsx @@ -18,7 +18,7 @@ export default function useLinks( searchByTextContent, }: LinkRequestQuery = { sort: 0 } ) { - const { links, setLinks, resetLinks } = useLinkStore(); + const { links, setLinks, resetLinks, selectedLinks, setSelectedLinks } = useLinkStore(); const router = useRouter(); const { reachedBottom, setReachedBottom } = useDetectPageBottom(); @@ -68,8 +68,12 @@ export default function useLinks( }; useEffect(() => { + // Save the selected links before resetting the links + // and then restore the selected links after resetting the links + const previouslySelected = selectedLinks resetLinks(); + setSelectedLinks(previouslySelected); getLinks(true); }, [ router, diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index 0a5196a7..1b626e60 100644 --- a/pages/collections/[id].tsx +++ b/pages/collections/[id].tsx @@ -170,7 +170,7 @@ export default function Index() {