|
1 | 1 | /* eslint-disable max-lines */
|
2 | 2 | import { usePageData } from '@rspress/runtime';
|
3 | 3 | import { SearchOptions, isProduction } from '@rspress/shared';
|
4 |
| -import { debounce, groupBy } from 'lodash-es'; |
| 4 | +import { isEqual, debounce, groupBy } from 'lodash-es'; |
5 | 5 | import { useEffect, useMemo, useRef, useState } from 'react';
|
6 | 6 | import { createPortal } from 'react-dom';
|
7 | 7 | import * as userSearchHooks from 'virtual-search-hooks';
|
@@ -175,7 +175,10 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
175 | 175 | ...Object.values(normalizeSuggestions(currentSuggestions)),
|
176 | 176 | );
|
177 | 177 | const suggestion = flatSuggestions[currentSuggestionIndex];
|
178 |
| - const isCurrent = currentSuggestions === searchResult[0].result; |
| 178 | + const isCurrent = isEqual( |
| 179 | + currentSuggestions, |
| 180 | + searchResult[0].result, |
| 181 | + ); |
179 | 182 | if (isCurrent) {
|
180 | 183 | window.location.href = isProduction()
|
181 | 184 | ? suggestion.link
|
@@ -384,9 +387,10 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
384 | 387 | setCurrentSuggestionIndex(suggestionIndex);
|
385 | 388 | }}
|
386 | 389 | closeSearch={() => setFocused(false)}
|
387 |
| - inCurrentDocIndex={ |
388 |
| - currentSuggestions === searchResult[0].result |
389 |
| - } |
| 390 | + inCurrentDocIndex={isEqual( |
| 391 | + currentSuggestions, |
| 392 | + searchResult[0].result, |
| 393 | + )} |
390 | 394 | scrollTo={scrollTo}
|
391 | 395 | />
|
392 | 396 | );
|
|
0 commit comments