Allow handling arbitrary text
Summary: When a user enters any arbitrary text, we will treat as an input for the search through the entire row. Based on feedback from https://fb.workplace.com/groups/flippersupport/permalink/1703929480087703/ Reviewed By: lblasa Differential Revision: D49911868 fbshipit-source-id: 4c569e4b01e468f0ca112ea4b00fe143b30bed2a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0346dc1120
commit
c4fbd10e68
@@ -37,6 +37,9 @@ type PowerSearchProps = {
|
||||
config: PowerSearchConfig;
|
||||
initialSearchExpression?: SearchExpressionTerm[];
|
||||
onSearchExpressionChange: (searchExpression: SearchExpressionTerm[]) => void;
|
||||
onConfirmUnknownOption?: (
|
||||
searchString: string,
|
||||
) => SearchExpressionTerm | undefined;
|
||||
};
|
||||
|
||||
const OPTION_KEY_DELIMITER = '::';
|
||||
@@ -45,6 +48,7 @@ export const PowerSearch: React.FC<PowerSearchProps> = ({
|
||||
config,
|
||||
initialSearchExpression,
|
||||
onSearchExpressionChange,
|
||||
onConfirmUnknownOption,
|
||||
}) => {
|
||||
const [searchExpression, setSearchExpression] = React.useState<
|
||||
IncompleteSearchExpressionTerm[]
|
||||
@@ -162,6 +166,21 @@ export const PowerSearch: React.FC<PowerSearchProps> = ({
|
||||
);
|
||||
});
|
||||
}}
|
||||
onConfirmUnknownOption={
|
||||
onConfirmUnknownOption
|
||||
? (searchString) => {
|
||||
const searchExpressionTerm =
|
||||
onConfirmUnknownOption(searchString);
|
||||
|
||||
if (searchExpressionTerm) {
|
||||
setSearchExpression((prevSearchExpression) => [
|
||||
...prevSearchExpression,
|
||||
searchExpressionTerm,
|
||||
]);
|
||||
}
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</PowerSearchContainer>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user