From 521f2393590a02601d611e893f8f3aefaa76069f Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Wed, 5 Feb 2025 02:40:26 +0000 Subject: [PATCH] show a placeholder --- .../app/src/components/SearchButton/index.jsx | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/packages/app/src/components/SearchButton/index.jsx b/packages/app/src/components/SearchButton/index.jsx index b78669e0..b5384875 100755 --- a/packages/app/src/components/SearchButton/index.jsx +++ b/packages/app/src/components/SearchButton/index.jsx @@ -5,55 +5,55 @@ import classnames from "classnames" import "./index.less" const SearchButton = (props) => { - const searchBoxRef = React.useRef(null) + const searchBoxRef = React.useRef(null) - const [value, setValue] = React.useState() - const [open, setOpen] = React.useState() + const [value, setValue] = React.useState() + const [open, setOpen] = React.useState() - const openSearchBox = (to) => { - to = to ?? !open - setOpen(to) + const openSearchBox = (to) => { + to = to ?? !open + setOpen(to) - if (to) { - searchBoxRef.current?.focus() - } - } + if (to) { + searchBoxRef.current?.focus() + } + } - const handleOnChange = (value) => { - setValue(value) + const handleOnChange = (value) => { + setValue(value) - if (!value || value.length === 0 || value === "" || value === " ") { - if (typeof props.onEmpty === "function") { - props.onEmpty() - } + if (!value || value.length === 0 || value === "" || value === " ") { + if (typeof props.onEmpty === "function") { + props.onEmpty() + } - return false - } + return false + } - if (typeof props.onChange === "function") { - props.onChange(value) - } - } + if (typeof props.onChange === "function") { + props.onChange(value) + } + } - return
openSearchBox(true)} - > - openSearchBox(true)} - onBlur={() => { - if (value.length === 0) { - openSearchBox(false) - } - }} - disabled={props.disabled} - /> -
+ return ( +
openSearchBox(true)}> + openSearchBox(true)} + onBlur={() => { + if (value.length === 0) { + openSearchBox(false) + } + }} + disabled={props.disabled} + /> +
+ ) } -export default SearchButton \ No newline at end of file +export default SearchButton