From 55b4716bac542b2faa50ec5dce0e281fcf48b1cc Mon Sep 17 00:00:00 2001 From: yangdx Date: Sat, 20 Sep 2025 14:35:41 +0800 Subject: [PATCH] fix(webui): resolve cmdk filtering issue preventing search history display - Fix AsyncSelect component where cmdk's internal filtering was hiding search history items - Change CommandItem value logic: use empty string when searchTerm is empty to match cmdk's filtering behavior - Ensure search history displays correctly on initial load regardless of current queryLabel value - Maintain proper selected state indication and all existing functionality - Preserve normal search behavior when user types in search input Fixes issue where dropdown only showed "*" and current queryLabel instead of full search history from localStorage. --- .../src/components/ui/AsyncSelect.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lightrag_webui/src/components/ui/AsyncSelect.tsx b/lightrag_webui/src/components/ui/AsyncSelect.tsx index 879237dd..ea5d4de2 100644 --- a/lightrag_webui/src/components/ui/AsyncSelect.tsx +++ b/lightrag_webui/src/components/ui/AsyncSelect.tsx @@ -248,21 +248,18 @@ export function AsyncSelect({ ))} - {options.map((option, index) => { + {options.map((option) => { const optionValue = getOptionValue(option); - // Use index as a safe value that won't be trimmed by cmdk - const safeValue = `option-${index}-${optionValue.length}`; + // Fix cmdk filtering issue: use empty string when search is empty + // This ensures all items are shown when searchTerm is empty + const itemValue = searchTerm.trim() === '' ? '' : optionValue; return ( { - // Extract the original value from the safe value - const selectedIndex = parseInt(selectedSafeValue.split('-')[1]); - const originalValue = getOptionValue(options[selectedIndex]); - console.log(`CommandItem onSelect: safeValue='${selectedSafeValue}', originalValue='${originalValue}' (length: ${originalValue.length})`); - handleSelect(originalValue); + value={itemValue} + onSelect={() => { + handleSelect(optionValue); }} className="truncate" >