Enable selecting items in the autocomplete picker component when a values in the query string are already provided in the URL.
Fixes https://github.com/backstage/backstage/issues/17021 Signed-off-by: headphonejames <generalfuzz@gmail.com>
This commit is contained in:
+2
-6
@@ -28,7 +28,6 @@ import {
|
||||
useEntityList,
|
||||
} from '../../hooks/useEntityListProvider';
|
||||
import { EntityFilter } from '../../types';
|
||||
import _ from 'lodash';
|
||||
|
||||
type KeysMatchingCondition<T, V, K> = T extends V ? K : never;
|
||||
type KeysMatching<T, V> = {
|
||||
@@ -97,13 +96,10 @@ export function EntityAutocompletePicker<
|
||||
// Set selected options on query parameter updates; this happens at initial page load and from
|
||||
// external updates to the page location
|
||||
useEffect(() => {
|
||||
if (
|
||||
queryParameters.length &&
|
||||
!_.isEqual(selectedOptions, queryParameters)
|
||||
) {
|
||||
if (queryParameters.length) {
|
||||
setSelectedOptions(queryParameters);
|
||||
}
|
||||
}, [selectedOptions, queryParameters]);
|
||||
}, [queryParameters]);
|
||||
|
||||
const availableOptions = Object.keys(availableValues ?? {});
|
||||
const shouldAddFilter = selectedOptions.length && availableOptions.length;
|
||||
|
||||
Reference in New Issue
Block a user