mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(frontend): enhance logic
This commit is contained in:
parent
7ddfdfc75a
commit
a29bb37890
@ -28,7 +28,7 @@ export const useQueryParam = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await router.replace(
|
await router.push(
|
||||||
{
|
{
|
||||||
query: updatedQuery,
|
query: updatedQuery,
|
||||||
},
|
},
|
||||||
|
@ -67,23 +67,24 @@ export const useSearch = <T>({
|
|||||||
queryParamValue?.toString() || "",
|
queryParamValue?.toString() || "",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (queryParamValue) {
|
||||||
|
setSearchText(queryParamValue.toString() || "");
|
||||||
|
} else {
|
||||||
|
if (searchText && ref.current) {
|
||||||
|
ref.current.value = "";
|
||||||
|
}
|
||||||
|
setSearchText("");
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [queryParamValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (searchText && ref.current) {
|
if (searchText && ref.current) {
|
||||||
ref.current.value = searchText;
|
ref.current.value = searchText;
|
||||||
}
|
}
|
||||||
}, [searchText]);
|
}, [searchText]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
queryParamKey &&
|
|
||||||
queryParamValue !== searchText &&
|
|
||||||
queryParamValue !== undefined
|
|
||||||
) {
|
|
||||||
setSearchText(queryParamValue.toString() || "");
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [queryParamValue, queryParamKey]);
|
|
||||||
|
|
||||||
const onSearch = debounce(
|
const onSearch = debounce(
|
||||||
async (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | string) => {
|
async (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | string) => {
|
||||||
const newSearchText = typeof e === "string" ? e : e.target.value;
|
const newSearchText = typeof e === "string" ? e : e.target.value;
|
||||||
|
Loading…
Reference in New Issue
Block a user