Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix selectedFolderId bug

Steven Tey994600cd636e
diff --git a/apps/web/ui/folders/folder-dropdown.tsx b/apps/web/ui/folders/folder-dropdown.tsx
index d447b47f0e..ac2b8a92d3 100644
--- a/apps/web/ui/folders/folder-dropdown.tsx
+++ b/apps/web/ui/folders/folder-dropdown.tsx
@@ -19,6 +19,7 @@ interface FolderDropdownProps {
buttonClassName?: string;
buttonTextClassName?: string;
disableAutoRedirect?: boolean; // decide if we should auto redirect to the folder after it's created
+ selectedFolderId?: string;
}
export const FolderDropdown = ({
@@ -28,6 +29,7 @@ export const FolderDropdown = ({
buttonClassName,
buttonTextClassName,
disableAutoRedirect = false,
+ selectedFolderId,
}: FolderDropdownProps) => {
const router = useRouter();
const { slug, plan } = useWorkspace();
@@ -39,7 +41,7 @@ export const FolderDropdown = ({
unsortedLinks,
);
- const folderId = searchParams.get("folderId");
+ const folderId = selectedFolderId || searchParams.get("folderId");
const { AddFolderModal, setShowAddFolderModal } = useAddFolderModal({
onSuccess: (folder) => {
diff --git a/apps/web/ui/modals/link-builder/index.tsx b/apps/web/ui/modals/link-builder/index.tsx
index 9578cc5b03..db9c9177d3 100644
--- a/apps/web/ui/modals/link-builder/index.tsx
+++ b/apps/web/ui/modals/link-builder/index.tsx
@@ -183,12 +183,6 @@ function LinkBuilderInner({
useEffect(() => {
if (key?.endsWith("-copy")) keyRef.current?.select();
}, []);
- const searchParamsFolderId = searchParams.get("folderId");
- useEffect(() => {
- if (searchParamsFolderId) {
- setValue("folderId", searchParamsFolderId);
- }
- }, [searchParamsFolderId]);
const { domains, loading, primaryDomain } = useAvailableDomains({
currentDomain: domain,
@@ -354,6 +348,9 @@ function LinkBuilderInner({
}}
buttonClassName="max-w-60 md:max-w-[24rem]"
buttonTextClassName="text-lg md:text-lg font-medium"
+ {...(props?.folderId && {
+ selectedFolderId: props.folderId,
+ })}
/>
<ChevronRight className="hidden size-4 text-neutral-500 md:block" />