diff --git a/src/components/LinkField.tsx b/src/components/LinkField.tsx index 5f40da2..deffe75 100644 --- a/src/components/LinkField.tsx +++ b/src/components/LinkField.tsx @@ -9,6 +9,7 @@ interface LinkFieldProps { placeholder?: string; disabled?: boolean; filters?: Record; + compact?: boolean; // ✅ Add this prop } const LinkField: React.FC = ({ @@ -19,6 +20,7 @@ const LinkField: React.FC = ({ placeholder, disabled = false, filters = {}, + compact = false, // ✅ Default to false }) => { const [searchResults, setSearchResults] = useState<{ value: string; description?: string }[]>([]); const [searchText, setSearchText] = useState(''); @@ -35,7 +37,6 @@ const LinkField: React.FC = ({ // Add filters if provided if (filters && Object.keys(filters).length > 0) { - // Convert filters to JSON string for Frappe API params.append('filters', JSON.stringify(filters)); } @@ -54,15 +55,13 @@ const LinkField: React.FC = ({ if (isDropdownOpen) { searchLink(searchText || ''); } - }, [isDropdownOpen, filters]); // Re-fetch when filters change + }, [isDropdownOpen, filters]); // Close dropdown when clicking outside useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (containerRef.current && !containerRef.current.contains(event.target as Node)) { setDropdownOpen(false); - - // Reset search text to current value when closing setSearchText(''); } }; @@ -85,20 +84,25 @@ const LinkField: React.FC = ({ }; return ( -
-