Fix filtering bugs

Summary: Doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU/edit#heading=h.pg8svtdjlx7

Reviewed By: antonk52

Differential Revision: D49411941

fbshipit-source-id: 530b0abcbba57e2503da4641d17fd1a507955b45
This commit is contained in:
Andrey Goncharov
2023-09-19 08:19:25 -07:00
committed by Facebook GitHub Bot
parent 6f38ecfd01
commit f6ffbfe3e2
5 changed files with 29 additions and 19 deletions

View File

@@ -84,17 +84,14 @@ export const PowerSearch: React.FC<PowerSearchProps> = ({
return groupedOptions;
}, [config.fields]);
const lastSearchTermHasSearchValue =
searchExpression.length > 0
? searchExpression[searchExpression.length - 1].searchValue !== undefined
: false;
const searchTermFinderRef = React.useRef<{
focus: () => void;
blur: () => void;
scrollTo: () => void;
}>(null);
console.log('searchExpression', searchExpression);
return (
<PowerSearchContainer>
<Space size={[theme.space.tiny, 0]}>
@@ -106,15 +103,10 @@ export const PowerSearch: React.FC<PowerSearchProps> = ({
}}
/>
{searchExpression.map((searchTerm, i) => {
const isLastTerm = i === searchExpression.length - 1;
return (
<PowerSearchTerm
key={i.toString()}
searchTerm={searchTerm}
searchValueRenderer={
lastSearchTermHasSearchValue || !isLastTerm ? 'button' : 'input'
}
onCancel={() => {
setSearchExpression((prevSearchExpression) => {
if (prevSearchExpression[i]) {