Skip to content

Commit

Permalink
fix: search click event (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
shelegdmitriy authored Jun 6, 2024
1 parent d8ef0aa commit 018ea0a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Navigation/Search.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const [value, setValue] = useState("");
const [isFocused, setIsFocused] = useState(false);
const [isCursorOutside, setIsCursorOutside] = useState(false);

const showTypeAheadDropdown = isFocused && !!value;

Expand All @@ -8,21 +9,29 @@ const handleOnInput = (value) => {
setIsFocused(!!value);
};

const handleInteractOutside = (e) => {
setIsFocused(false);
const handleInteractOutside = (value) => {
setIsCursorOutside(!value);
};

const handleFocusChange = () => {
setIsFocused(!isFocused);
};

const handleOnBlur = () => {
setIsFocused(!isCursorOutside);
};

return (
<HoverCard.Root openDelay={200} closeDelay={300} open={showTypeAheadDropdown}>
<HoverCard.Root openDelay={200} closeDelay={300} open={showTypeAheadDropdown} onOpenChange={handleInteractOutside}>
<HoverCard.Trigger asChild>
<div>
<Widget
src="${REPL_ACCOUNT}/widget/DIG.InputSearch"
props={{
onQueryChange: handleOnInput,
placeholder: "Search NEAR",
onBlur: () => setIsFocused(false),
onFocus: () => setIsFocused(true),
onBlur: handleOnBlur,
onFocus: handleFocusChange,
}}
/>
</div>
Expand Down

0 comments on commit 018ea0a

Please sign in to comment.