From 6054f6dd9df4d9b88a4a99b592369a64667c918c Mon Sep 17 00:00:00 2001 From: rizky Date: Sun, 28 Jul 2024 21:29:04 -0700 Subject: [PATCH] fix --- comps/ui/typeahead-opt.tsx | 19 ++++++++++++++++++- comps/ui/typeahead.tsx | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/comps/ui/typeahead-opt.tsx b/comps/ui/typeahead-opt.tsx index b6645ad..9e9a316 100755 --- a/comps/ui/typeahead-opt.tsx +++ b/comps/ui/typeahead-opt.tsx @@ -18,6 +18,7 @@ export const TypeaheadOptions: FC<{ }) => boolean; onSelect?: (value: string) => void; searching?: boolean; + searchText?: string; width?: number; }> = ({ popup, @@ -29,6 +30,7 @@ export const TypeaheadOptions: FC<{ selected, onSelect, searching, + searchText, showEmpty, width, }) => { @@ -87,7 +89,22 @@ export const TypeaheadOptions: FC<{ <> {options.length === 0 && (
- — Empty — + {!searchText ? ( + <>— Empty — + ) : ( + <> + Search + + "{searchText}" + + not found + + )}
)} diff --git a/comps/ui/typeahead.tsx b/comps/ui/typeahead.tsx index d51aea8..350ee58 100755 --- a/comps/ui/typeahead.tsx +++ b/comps/ui/typeahead.tsx @@ -213,6 +213,8 @@ export const Typeahead: FC<{ local.open = true; if (e.key === "ArrowDown") { e.preventDefault(); + e.stopPropagation(); + const idx = options.findIndex((item) => { if (item.value === local.select?.value) return true; }); @@ -229,6 +231,7 @@ export const Typeahead: FC<{ } if (e.key === "ArrowUp") { e.preventDefault(); + e.stopPropagation(); const idx = options.findIndex((item) => { if (item.value === local.select?.value) return true; @@ -392,6 +395,7 @@ export const Typeahead: FC<{ open={local.open} options={options} searching={local.search.searching} + searchText={local.search.input} onSelect={(value) => { local.open = false; resetSearch();