diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/ContractorUploadModal.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/ContractorUploadModal.tsx index eb6b66d..1fa07b7 100644 --- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/ContractorUploadModal.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/ContractorUploadModal.tsx @@ -1,7 +1,6 @@ "use client"; import { useEffect, useRef, useState } from "react"; -import { createPortal } from "react-dom"; import { Dialog, DialogContent, @@ -256,138 +255,37 @@ function PasGuidancePanel() { ); } -// ── Searchable DocType combobox ──────────────────────────────────────────── +// ── DocType select ──────────────────────────────────────────────────────── function DocTypeSelect({ value, onChange, showHint = false }: { value: string; onChange: (v: string) => void; showHint?: boolean }) { const selected = FILE_TYPE_OPTIONS.find((o) => o.value === value); - const [open, setOpen] = useState(false); - const [query, setQuery] = useState(""); - const [dropdownStyle, setDropdownStyle] = useState({}); - const triggerRef = useRef(null); - const inputRef = useRef(null); - - function openDropdown() { - if (!triggerRef.current) return; - const rect = triggerRef.current.getBoundingClientRect(); - const spaceBelow = window.innerHeight - rect.bottom; - const dropdownHeight = 280; - const showAbove = spaceBelow < dropdownHeight && rect.top > dropdownHeight; - setDropdownStyle({ - position: "fixed", - left: rect.left, - width: rect.width, - zIndex: 9999, - ...(showAbove - ? { bottom: window.innerHeight - rect.top + 4 } - : { top: rect.bottom + 4 }), - }); - setOpen(true); - } - - function close() { - setOpen(false); - setQuery(""); - } - - function select(val: string) { - onChange(val); - close(); - } - - // Focus search input when opening - useEffect(() => { - if (open) setTimeout(() => inputRef.current?.focus(), 0); - }, [open]); - - const filtered = query.trim() - ? FILE_TYPE_OPTIONS.filter((o) => - o.label.toLowerCase().includes(query.toLowerCase()) || - o.group.toLowerCase().includes(query.toLowerCase()) - ) - : null; return (
- {/* Trigger */} - - - {open && typeof document !== "undefined" && createPortal( - <> - {/* Transparent overlay — position:fixed escapes overflow:hidden, catches all outside clicks */} -
- - {/* Dropdown — above the overlay */} -
-
- setQuery(e.target.value)} - placeholder="Search…" - className="w-full rounded border border-gray-200 px-2 py-1 text-xs outline-none focus:border-brandblue" - /> -
-
- {filtered ? ( - filtered.length === 0 ? ( -

No results

- ) : ( - filtered.map((o) => ( - - )) - ) - ) : ( - FILE_TYPE_GROUPS.map((group) => { - const items = FILE_TYPE_OPTIONS.filter((o) => o.group === group); - if (!items.length) return null; - return ( -
-

- {group} -

- {items.map((o) => ( - - ))} -
- ); - }) - )} -
-
- , - document.body - )} - + {showHint && selected?.hint && (

{selected.hint}

)}