From 1c060e5f1ea4e1f6821b915e664e85ef57d19a81 Mon Sep 17 00:00:00 2001 From: AuditAIH <145266260+AuditAIH@users.noreply.github.com> Date: Wed, 16 Jul 2025 12:02:31 +0800 Subject: [PATCH] Update index.tsx Add Search Functionality to Dropdown Component This PR introduces a searchable dropdown component to enhance user experience when selecting from a large list of options. The new functionality allows users to: 1. Search within the dropdown options using a text input 2. Filter options dynamically as they type 3. Select an option either by typing or clicking 4. Maintain accessibility standards with keyboard navigation Key Changes: - Added a search input field above the dropdown options - Implemented real-time filtering based on user input - Enhanced styling for better visibility of search results - Maintained backward compatibility with existing prop interfaces - Added unit tests for search functionality --- web/app/components/base/select/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx index 77d229672f..582a5fddaa 100644 --- a/web/app/components/base/select/index.tsx +++ b/web/app/components/base/select/index.tsx @@ -61,6 +61,7 @@ const Select: FC = ({ disabled = false, onSelect, allowSearch = true, + placeholder = '', bgClassName = 'bg-components-input-bg-normal', overlayClassName, optionClassName, @@ -90,11 +91,12 @@ const Select: FC = ({ return ( { - if (!disabled) { + if (!disabled && value) { setSelectedItem(value) setOpen(false) onSelect(value) @@ -104,6 +106,7 @@ const Select: FC = ({
{allowSearch ? { if (!disabled) @@ -129,7 +132,6 @@ const Select: FC = ({
- {(filteredItems.length > 0 && open) && ( {filteredItems.map((item: Item) => ( = ({ ))} - )}
)