[ui][typeahead] allow typeahead to be cleared

This commit is contained in:
Yangshun Tay
2022-10-30 09:23:03 +08:00
parent a103879b5c
commit f7ff20bb22
11 changed files with 27 additions and 7 deletions

View File

@ -34,7 +34,7 @@ type Props = Readonly<{
value: string,
event: React.ChangeEvent<HTMLInputElement>,
) => void;
onSelect: (option: TypeaheadOption) => void;
onSelect: (option: TypeaheadOption | null) => void;
options: ReadonlyArray<TypeaheadOption>;
textSize?: TypeaheadTextSize;
value?: TypeaheadOption;
@ -102,10 +102,6 @@ export default function Typeahead({
// @ts-ignore
value={value}
onChange={(newValue) => {
if (newValue == null) {
return;
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onSelect(newValue as TypeaheadOption);