From 8d479ac24cd1a94acfed288974957784b8052db7 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Mon, 29 Dec 2025 19:54:32 +0530 Subject: [PATCH] [WEB-5822] fix: migrate ImagePickerPopover to Propel Tabs component and render only enabled tabs #8290 - 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 a1b21ddd0..42712ab71 100644 --- a/apps/web/core/components/core/image-picker-popover.tsx +++ b/apps/web/core/components/core/image-picker-popover.tsx @@ -5,10 +5,11 @@ 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 { Tabs } from "@plane/propel/tabs"; import { Button, getButtonStyling } from "@plane/propel/button"; import { TOAST_TYPE, setToast } from "@plane/propel/toast"; import { EFileAssetType } from "@plane/types"; @@ -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), @@ -191,25 +194,19 @@ export const ImagePickerPopover = observer(function ImagePickerPopover(props: Pr >
- - - {tabOptions.map((tab) => ( - - `rounded-sm px-4 py-1 text-center text-13 outline-none transition-colors ${ - selected ? "bg-accent-primary text-on-color" : "text-primary" - }` - } - > + + + {enabledTabs.map((tab) => ( + {tab.title} - + ))} - - - + + +
+ {(unsplashImages || !unsplashError) && ( <>
@@ -276,8 +273,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"}
- - - + +
+
)}