This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new 4be9f663ab8 [fix] fix search bar no result (#3657)
4be9f663ab8 is described below
commit 4be9f663ab849e16bd5fd88f6421377360cca593
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Sat May 16 08:22:38 2026 -0700
[fix] fix search bar no result (#3657)
---
src/theme/SearchBar/SearchBar.jsx | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/theme/SearchBar/SearchBar.jsx
b/src/theme/SearchBar/SearchBar.jsx
index d3ed74716f5..384e9d95222 100644
--- a/src/theme/SearchBar/SearchBar.jsx
+++ b/src/theme/SearchBar/SearchBar.jsx
@@ -109,6 +109,10 @@ export default function SearchBar({ handleSearchBarToggle
}) {
const [inputChanged, setInputChanged] = useState(false);
const [inputValue, setInputValue] = useState('');
const search = useRef(null);
+ // Bumped on every loadIndex call so a stale call (whose async fetches
+ // finished after a newer call started) can abort before wrapping the
+ // input with a second autocomplete instance — see #3655 race.
+ const loadToken = useRef(0);
const prevSearchContext = useRef('');
const [searchContext, setSearchContext] = useState('');
useEffect(() => {
@@ -145,13 +149,19 @@ export default function SearchBar({ handleSearchBarToggle
}) {
// Do not load the index (again) if its already loaded or in
the process of being loaded.
return;
}
+ const myToken = ++loadToken.current;
indexStateMap.current.set(searchContext, 'loading');
search.current?.autocomplete.destroy();
+ search.current = null;
setLoading(true);
const [autoComplete] = await Promise.all([
fetchAutoCompleteJS(),
fetchIndexesByWorker(versionUrl, searchContext),
]);
+ if (myToken !== loadToken.current) {
+ // Superseded by a newer loadIndex; don't mount a second
autocomplete on the same input.
+ return;
+ }
const searchFooterLinkElement = ({ query, isEmpty }) => {
const a = document.createElement('a');
const params = new URLSearchParams();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]