Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/PropertySearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const PropertySearchInner = ({
const debouncedValue = useDebounce(value, 300);

// Use React Query for autocomplete suggestions
const { data: suggestions = [], isLoading } = usePropertyAutocompleteQuery(debouncedValue);
const { data: suggestions = EMPTY_SUGGESTIONS, isLoading } = usePropertyAutocompleteQuery(debouncedValue);

// Close dropdown when clicking outside
useEffect(() => {
Expand Down Expand Up @@ -113,8 +113,14 @@ const PropertySearchInner = ({
inputRef.current?.focus();
}, [onChange]);

const showDropdown = isFocused && (suggestions.length > 0 || isLoading || showHistory);
const activeOptionId = selectedIndex >= 0 ? `${listboxId}-option-${selectedIndex}` : undefined;
const showDropdown = useMemo(
() => isFocused && (suggestions.length > 0 || isLoading || showHistory),
[isFocused, suggestions.length, isLoading, showHistory]
);
const activeOptionId = useMemo(
() => (selectedIndex >= 0 ? `${listboxId}-option-${selectedIndex}` : undefined),
[listboxId, selectedIndex]
);
// Keep the input and suggestion list in sync for assistive technologies.

return (
Expand Down
Loading