Transformations: Transformation refID filters should include non-existant refIDs if no recovery was made (#109008)
* Show refIds if nothing is recovered * Add test * Preserve function returning undefined if there are no recovered or selected refIDs * cuter * add context and remove testing by sibling --------- Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
@@ -109,4 +109,10 @@ describe('RefIDMultiPicker', () => {
|
||||
expect(mockOnChange).toHaveBeenLastCalledWith(['A', 'B']);
|
||||
/* eslint-enable testing-library/prefer-user-event */
|
||||
});
|
||||
|
||||
// in the scenario where a refID filter was saved, but is no longer valid, it should still show.
|
||||
it('Should display a refID that does not exist in the selection', async () => {
|
||||
multiSetup({ value: '/^(?:merge-A-B-C)$/' });
|
||||
expect(screen.getByText('merge-A-B-C')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -129,7 +129,6 @@ export function RefIDMultiPicker({ value, data, onChange, placeholder }: MultiPr
|
||||
|
||||
const currentValue = useMemo(() => {
|
||||
let extractedRefIds = new Set<string>();
|
||||
|
||||
if (value) {
|
||||
if (value.startsWith('/^')) {
|
||||
try {
|
||||
@@ -152,8 +151,10 @@ export function RefIDMultiPicker({ value, data, onChange, placeholder }: MultiPr
|
||||
}
|
||||
|
||||
const newRefIds = [...extractedRefIds].map(toOption);
|
||||
const recoveredRefIDs =
|
||||
recoverMultiRefIdMissing(newRefIds, priorSelectionState.refIds, priorSelectionState.value) ?? [];
|
||||
|
||||
return recoverMultiRefIdMissing(newRefIds, priorSelectionState.refIds, priorSelectionState.value);
|
||||
return recoveredRefIDs.length > 0 ? recoveredRefIDs : newRefIds.length > 0 ? newRefIds : undefined;
|
||||
}, [value, listOfRefIds, priorSelectionState]);
|
||||
|
||||
const onFilterChange = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user