Skip to content

Commit e37877d

Browse files
authored
fix: search item click target set (#1129)
1 parent 2f6673d commit e37877d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/theme-default/src/components/Search/SearchPanel.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable max-lines */
22
import { usePageData } from '@rspress/runtime';
33
import { SearchOptions, isProduction } from '@rspress/shared';
4-
import { debounce, groupBy } from 'lodash-es';
4+
import { isEqual, debounce, groupBy } from 'lodash-es';
55
import { useEffect, useMemo, useRef, useState } from 'react';
66
import { createPortal } from 'react-dom';
77
import * as userSearchHooks from 'virtual-search-hooks';
@@ -175,7 +175,10 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
175175
...Object.values(normalizeSuggestions(currentSuggestions)),
176176
);
177177
const suggestion = flatSuggestions[currentSuggestionIndex];
178-
const isCurrent = currentSuggestions === searchResult[0].result;
178+
const isCurrent = isEqual(
179+
currentSuggestions,
180+
searchResult[0].result,
181+
);
179182
if (isCurrent) {
180183
window.location.href = isProduction()
181184
? suggestion.link
@@ -384,9 +387,10 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
384387
setCurrentSuggestionIndex(suggestionIndex);
385388
}}
386389
closeSearch={() => setFocused(false)}
387-
inCurrentDocIndex={
388-
currentSuggestions === searchResult[0].result
389-
}
390+
inCurrentDocIndex={isEqual(
391+
currentSuggestions,
392+
searchResult[0].result,
393+
)}
390394
scrollTo={scrollTo}
391395
/>
392396
);

0 commit comments

Comments
 (0)