Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/autocomplete filter not behaving correctly using or operator page 4078 #3497

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
11 changes: 8 additions & 3 deletions src/components/autocompleteInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
const [interactionFilter, setInteractionFilter] = useState({});
const { current: labelControlRef } = useRef(generateUUID());
const isNumberType = type === 'number';
const EMPTY_LABEL = '-- empty --';

const validPattern = pattern || null;
const validMinlength = minlength || null;
Expand Down Expand Up @@ -331,9 +332,13 @@

const numberDebouncedInputValue = parseFloat(debouncedInputValue, 10);

// There is an empty string as fallback, because empty label is not a valid value to search on
const textDebouncedInputValue =
debouncedInputValue === EMPTY_LABEL ? '' : debouncedInputValue;

const parsedDebouncedValue = searchPropIsNumber
? numberDebouncedInputValue
: debouncedInputValue;
: textDebouncedInputValue;

const currentSearchValue =
typeof value === 'string' ? value : value[searchProp.name];
Expand All @@ -357,7 +362,7 @@
const newFilter = {
[labelPropIsNumber ? 'eq' : 'matches']: labelPropIsNumber
? numberDebouncedInputValue
: debouncedInputValue,
: textDebouncedInputValue,
};
const resolvedUuids = labelPropertyPath.map((u) => getProperty(u).name);
const resolvedFilter = resolvedUuids.reduceRight(
Expand Down Expand Up @@ -691,7 +696,7 @@
}

return optionLabel === '' || optionLabel === null
? '-- empty --'
? EMPTY_LABEL
: optionLabel.toString();
};

Expand Down
Loading