Skip to content

Commit 1dc2f1f

Browse files
committed
fix: incorrect detail display for each item
1 parent bf29584 commit 1dc2f1f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/SearchDocumentation.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function SearchDocumentation(props: { id: DocID; quickSearch?: string })
1111
const tags = useMemo(() => Object.keys(currentDocs), [currentDocs]);
1212
const [searchText, setSearchText] = useState(props.quickSearch || "");
1313
const [searchTag, setSearchTag] = useState<Tags>(tags[0] as Tags);
14-
const [currentIdx, setCurrentIdx] = useState(0);
14+
const [currentIdx, setCurrentIdx] = useState<string | null>(null);
1515
const currentAPI = currentDocs[searchTag]!;
1616

1717
let isLoading = false;
@@ -47,19 +47,19 @@ export function SearchDocumentation(props: { id: DocID; quickSearch?: string })
4747
throttle={true}
4848
navigationTitle={DocID[props.id] || "No Title"}
4949
isLoading={isLoading || searchResults === undefined}
50-
isShowingDetail={searchResults?.[currentIdx]?.content != undefined}
50+
isShowingDetail={searchResults.find((item) => item.id === currentIdx)?.content != undefined}
5151
onSearchTextChange={setSearchText}
5252
searchText={searchText}
5353
onSelectionChange={(id) => {
54-
setCurrentIdx(parseInt(id || "0"));
54+
setCurrentIdx(id || "0");
5555
}}
5656
searchBarAccessory={
5757
<List.Dropdown
5858
tooltip="Select Tag"
5959
storeValue
6060
onChange={(tag) => {
6161
setSearchTag(tag as Tags);
62-
setCurrentIdx(0);
62+
setCurrentIdx(null);
6363
}}
6464
>
6565
{tags.map((tag) => (

0 commit comments

Comments
 (0)