Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 11, 2024
2 parents 11e3e49 + c6156a8 commit 4d2b2a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/components/ui-lib.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
border: none;
outline: none;
font-size: 14px;
text-align: left;
}

&-search-input:focus {
Expand Down
16 changes: 15 additions & 1 deletion app/components/ui-lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,27 @@ export function SearchSelector<T>(props: {
}
};

const { items, onClose } = props;
// 过滤列表项
const filteredItems = props.items.filter(
const filteredItems = items.filter(
(item) =>
item.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
(item.subTitle &&
item.subTitle.toLowerCase().includes(searchQuery.toLowerCase())),
);

useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") {
onClose?.();
}
};
document.addEventListener("keydown", handleKeyDown);
return () => {
document.removeEventListener("keydown", handleKeyDown);
};
}, [onClose]);

return (
<div className={styles["selector"]} onClick={() => props.onClose?.()}>
<div
Expand All @@ -522,6 +535,7 @@ export function SearchSelector<T>(props: {
<div className={styles["selector-search"]}>
<input
type="text"
autoFocus
className={styles["selector-search-input"]}
placeholder="search model"
value={searchQuery}
Expand Down

0 comments on commit 4d2b2a1

Please sign in to comment.