diff --git a/src-web/components/GraphQLDocsExplorer.tsx b/src-web/components/GraphQLDocsExplorer.tsx
index 4306e5f1..a3ad5fc4 100644
--- a/src-web/components/GraphQLDocsExplorer.tsx
+++ b/src-web/components/GraphQLDocsExplorer.tsx
@@ -26,6 +26,7 @@ import { Fragment, memo, useCallback, useMemo, useRef, useState } from 'react';
import { showGraphQLDocExplorerAtom } from '../atoms/graphqlSchemaAtom';
import { useDebouncedValue } from '../hooks/useDebouncedValue';
import { useRandomKey } from '../hooks/useRandomKey';
+import { useStateWithDeps } from '../hooks/useStateWithDeps';
import { jotaiStore } from '../lib/jotai';
import { CountBadge } from './core/CountBadge';
import { Icon } from './core/Icon';
@@ -63,10 +64,10 @@ export const GraphQLDocsExplorer = memo(function GraphQLDocsExplorer({
return (
-
+
{activeItem == null ? (
-
+
Root Types
@@ -597,7 +598,9 @@ function GqlSchemaSearch({
setItem: (t: ExplorerItem) => void;
className?: string;
}) {
- const [activeResult, setActiveResult] = useState
(null);
+ const [activeResult, setActiveResult] = useStateWithDeps(null, [
+ currentItem,
+ ]);
const [forceRefreshKey, regenerateForceRefreshKey] = useRandomKey();
const [focused, setFocused] = useState(false);
const [value, setValue] = useState('');
@@ -680,7 +683,7 @@ function GqlSchemaSearch({
}
}
},
- [results, activeIndex, activeResult, setItem, currentItem],
+ [results, activeIndex, setActiveResult, activeResult, setItem, currentItem],
);
if (!canSearch) return null;
@@ -709,16 +712,14 @@ function GqlSchemaSearch({
}
onChange={setValue}
onKeyDownCapture={handleKeyDown}
+ onFocus={() => setFocused(true)}
onBlur={() => {
+ setValue('');
+ regenerateForceRefreshKey();
setTimeout(() => {
setFocused(false);
- setValue('');
- regenerateForceRefreshKey();
}, 100);
}}
- onFocus={() => {
- setFocused(true);
- }}
/>