remove the selectedOptions check from the useEffect hook to allow updates to options when options are included in the query string.

Signed-off-by: headphonejames <generalfuzz@gmail.com>
This commit is contained in:
headphonejames
2023-04-10 09:22:09 -07:00
parent 2190368b52
commit 8c7d59c923
@@ -95,12 +95,11 @@ export function EntityAutocompletePicker<
// Set selected options on query parameter updates; this happens at initial page load and from
// external updates to the page location
const [prevQueryParameters, setQueryParameter] = useState(queryParameters);
// if the query parameter has changed, update the selected options
if (queryParameters !== prevQueryParameters) {
setSelectedOptions(queryParameters);
setQueryParameter(queryParameters);
}
useEffect(() => {
if (queryParameters.length) {
setSelectedOptions(queryParameters);
}
}, [queryParameters]);
const availableOptions = Object.keys(availableValues ?? {});
const shouldAddFilter = selectedOptions.length && availableOptions.length;