|
|
@@ -1,4 +1,6 @@
|
|
|
-import React, { useState, useCallback, useRef } from 'react';
|
|
|
+import React, {
|
|
|
+ useState, useCallback, useRef, useEffect,
|
|
|
+} from 'react';
|
|
|
|
|
|
import assert from 'assert';
|
|
|
|
|
|
@@ -38,9 +40,13 @@ export const GlobalSearch = (props: GlobalSearchProps): JSX.Element => {
|
|
|
const { data: currentPagePath } = useCurrentPagePath();
|
|
|
|
|
|
const [text, setText] = useState('');
|
|
|
- const [isScopeChildren, setScopeChildren] = useState<boolean|undefined>(isSearchScopeChildrenAsDefault);
|
|
|
+ const [isScopeChildren, setScopeChildren] = useState<boolean|undefined>(isSearchScopeChildrenAsDefault ?? false);
|
|
|
const [isFocused, setFocused] = useState<boolean>(false);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ setScopeChildren(isSearchScopeChildrenAsDefault);
|
|
|
+ }, [isSearchScopeChildrenAsDefault]);
|
|
|
+
|
|
|
|
|
|
const gotoPage = useCallback((data: IPageWithSearchMeta[]) => {
|
|
|
assert(data.length > 0);
|
|
|
@@ -73,6 +79,7 @@ export const GlobalSearch = (props: GlobalSearchProps): JSX.Element => {
|
|
|
|
|
|
const isIndicatorShown = !isFocused && (text.length === 0);
|
|
|
|
|
|
+
|
|
|
if (isScopeChildren == null || isSearchServiceReachable == null) {
|
|
|
return <></>;
|
|
|
}
|
|
|
@@ -116,7 +123,7 @@ export const GlobalSearch = (props: GlobalSearchProps): JSX.Element => {
|
|
|
</div>
|
|
|
<SearchForm
|
|
|
ref={globalSearchFormRef}
|
|
|
- isSearchServiceReachable={isSearchServiceReachable}
|
|
|
+ isSearchServiceReachable={isSearchServiceReachable || false}
|
|
|
dropup={dropup}
|
|
|
onChange={gotoPage}
|
|
|
onBlur={() => setFocused(false)}
|