From 9f7b46c6c71565d3c9a31ab301076ed3695c4585 Mon Sep 17 00:00:00 2001 From: Randi Mays <19175324+randimays@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:12:14 -0600 Subject: [PATCH] Got initial dropdown population working --- .../components/search-form/autosuggest/index.jsx | 12 ++++++++---- .../search-form/location/AddressAutosuggest.jsx | 5 +++-- .../service-type/VAMCServiceAutosuggest.jsx | 1 - .../facility-locator/hooks/useServiceType.jsx | 1 + .../tests/hooks/useServiceType.unit.spec.js | 2 +- src/applications/facility-locator/types/index.js | 4 +--- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/applications/facility-locator/components/search-form/autosuggest/index.jsx b/src/applications/facility-locator/components/search-form/autosuggest/index.jsx index 7b877085b2cf..c9a6175b0717 100644 --- a/src/applications/facility-locator/components/search-form/autosuggest/index.jsx +++ b/src/applications/facility-locator/components/search-form/autosuggest/index.jsx @@ -13,7 +13,6 @@ import { srClearOnBlur, srKeepOnBlur } from './StateReducer'; function Autosuggest({ // downshift props handleOnSelect, - defaultSelectedItem, initialSelectedItem = null, inputValue, itemToString = toDisplay, @@ -30,7 +29,6 @@ function Autosuggest({ downshiftInputProps, // options for the autosuggest to show options, - minCharacters = 3, // only trigger update after n=3 characters noItemsMessage = 'No results found', shouldShowNoResults = true, // showError - use the usa-input-error class to show the error @@ -44,6 +42,7 @@ function Autosuggest({ isLoading = false, loadingMessage = '', AutosuggestOptionComponent = AutosuggestOption, + showOptionsRestriction = undefined, }) { const { isOpen, @@ -60,7 +59,6 @@ function Autosuggest({ initialSelectedItem, inputId, onSelectedItemChange: handleOnSelect, - defaultSelectedItem, onInputValueChange, inputValue, isItemDisabled, @@ -72,6 +70,12 @@ function Autosuggest({ selectItem(null); }; + let shouldBeShown = isOpen; + + if (showOptionsRestriction !== undefined) { + shouldBeShown = isOpen && showOptionsRestriction; + } + return (