From e4ccda309f045450b11bb7b156f501ed4ed21ef5 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Wed, 10 Dec 2025 15:26:09 +0530 Subject: [PATCH] fix: migrate ImagePickerPopover to Propel Tabs component and render only enabled tabs - Replace custom tab implementation with Propel Tabs - Dynamically render only enabled tabs based on configuration - Filter tabs by isEnabled property for cleaner conditional rendering - Improve tab navigation and accessibility with Propel components --- .../components/core/image-picker-popover.tsx | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/apps/web/core/components/core/image-picker-popover.tsx b/apps/web/core/components/core/image-picker-popover.tsx index f1f7bdcc64..adebf2b301 100644 --- a/apps/web/core/components/core/image-picker-popover.tsx +++ b/apps/web/core/components/core/image-picker-popover.tsx @@ -5,11 +5,12 @@ import { useDropzone } from "react-dropzone"; import type { Control } from "react-hook-form"; import { Controller } from "react-hook-form"; import useSWR from "swr"; -import { Tab, Popover } from "@headlessui/react"; +import { Popover } from "@headlessui/react"; // plane imports import { ACCEPTED_COVER_IMAGE_MIME_TYPES_FOR_REACT_DROPZONE, MAX_FILE_SIZE } from "@plane/constants"; import { useOutsideClickDetector } from "@plane/hooks"; import { Button } from "@plane/propel/button"; +import { Tabs } from "@plane/propel/tabs"; import { TOAST_TYPE, setToast } from "@plane/propel/toast"; import { EFileAssetType } from "@plane/types"; import { Input, Loader } from "@plane/ui"; @@ -80,6 +81,8 @@ export const ImagePickerPopover = observer(function ImagePickerPopover(props: Pr [hasUnsplashConfigured] ); + const enabledTabs = useMemo(() => tabOptions.filter((tab) => tab.isEnabled), [tabOptions]); + const { data: unsplashImages, error: unsplashError } = useSWR( `UNSPLASH_IMAGES_${searchParams}`, () => fileService.getUnsplashImages(searchParams), @@ -195,25 +198,19 @@ export const ImagePickerPopover = observer(function ImagePickerPopover(props: Pr >
- - - {tabOptions.map((tab) => ( - - `rounded px-4 py-1 text-center text-sm outline-none transition-colors ${ - selected ? "bg-custom-primary text-white" : "text-custom-text-100" - }` - } - > + + + {enabledTabs.map((tab) => ( + {tab.title} - + ))} - - - + + +
+ {(unsplashImages || !unsplashError) && ( <>
@@ -280,8 +277,8 @@ export const ImagePickerPopover = observer(function ImagePickerPopover(props: Pr )} )} - - + +
{Object.values(STATIC_COVER_IMAGES).map((imageUrl, index) => (
))}
- - + +
- {isImageUploading ? "Uploading..." : "Upload & Save"} + {isImageUploading ? "Uploading" : "Upload & Save"}
- - - + +
+
)}