Skip to content

Commit

Permalink
feat: add keyup event to search input (#163)
Browse files Browse the repository at this point in the history
Optimize the operation path, before it required a mouse click every time to get to the preview page
liuxingyu521 authored Jun 29, 2024
1 parent a2a4ef1 commit 89322d9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/components/Search.tsx
Original file line number Diff line number Diff line change
@@ -37,6 +37,12 @@ export default function Search() {
},
]);
const name = pkg && pkg.name ? `${pkg.name}@${pkg.version}` : pkgname;
const gotoPreview = () => {
if (value) {
dispatch.global.update({ showSearch: false });
navigate(`/pkg/${value}`);
}
}
return (
<Fragment>
<Input
@@ -47,14 +53,14 @@ export default function Search() {
onChange={(e) => {
setValue(e.target.value);
}}
onKeyUp={(e) => {
if (e.key === "Enter") {
gotoPreview();
}
}}
addonAfter={
<Button
onClick={() => {
if (value) {
dispatch.global.update({ showSearch: false });
navigate(`/pkg/${value}`);
}
}}
onClick={gotoPreview}
icon="arrow-right"
size="small"
basic

0 comments on commit 89322d9

Please sign in to comment.