|
@@ -1,14 +1,16 @@
|
|
|
import React, {
|
|
import React, {
|
|
|
- FC, useState, useCallback,
|
|
|
|
|
|
|
+ FC, useState, useCallback, useRef,
|
|
|
} from 'react';
|
|
} from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
import { IPage } from '~/interfaces/page';
|
|
import { IPage } from '~/interfaces/page';
|
|
|
|
|
+import { IFocusable } from '~/client/interfaces/focusable';
|
|
|
|
|
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
|
|
|
|
|
import SearchForm from '../SearchForm';
|
|
import SearchForm from '../SearchForm';
|
|
|
|
|
+import { useGlobalSearchFormRef } from '~/stores/ui';
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
@@ -21,6 +23,10 @@ const GlobalSearch: FC<Props> = (props: Props) => {
|
|
|
const { appContainer, dropup } = props;
|
|
const { appContainer, dropup } = props;
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
+ const globalSearchFormRef = useRef<IFocusable>(null);
|
|
|
|
|
+
|
|
|
|
|
+ useGlobalSearchFormRef(globalSearchFormRef);
|
|
|
|
|
+
|
|
|
const [text, setText] = useState('');
|
|
const [text, setText] = useState('');
|
|
|
const [isScopeChildren, setScopeChildren] = useState<boolean>(appContainer.getConfig().isSearchScopeChildrenAsDefault);
|
|
const [isScopeChildren, setScopeChildren] = useState<boolean>(appContainer.getConfig().isSearchScopeChildrenAsDefault);
|
|
|
|
|
|
|
@@ -70,6 +76,7 @@ const GlobalSearch: FC<Props> = (props: Props) => {
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<SearchForm
|
|
<SearchForm
|
|
|
|
|
+ ref={globalSearchFormRef}
|
|
|
isSearchServiceReachable={isSearchServiceReachable}
|
|
isSearchServiceReachable={isSearchServiceReachable}
|
|
|
dropup={dropup}
|
|
dropup={dropup}
|
|
|
onChange={gotoPage}
|
|
onChange={gotoPage}
|