Skip to content

Commit

Permalink
fix: link error when use keyboard to enter search result (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 authored May 17, 2024
1 parent 391499f commit 4a34667
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/theme-default/src/components/Search/SearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
siteData,
page: { lang, version },
} = usePageData();
const { sidebar, searchPlaceholderText = 'Search Docs' } = useLocaleSiteData();
const { sidebar, searchPlaceholderText = 'Search Docs' } =
useLocaleSiteData();
const { search, title: siteTitle } = siteData;
const versionedSearch =
search && search.mode !== 'remote' && search.versioned;
Expand Down Expand Up @@ -170,7 +171,11 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
currentSuggestionIndex >= 0 &&
currentRenderType === RenderType.Default
) {
const suggestion = currentSuggestions[currentSuggestionIndex];
// the ResultItem has been normalized to display
const flatSuggestions = [].concat(
...Object.values(normalizeSuggestions(currentSuggestions)),
);
const suggestion = flatSuggestions[currentSuggestionIndex];
const isCurrent = currentSuggestions === searchResult[0].result;
if (isCurrent) {
window.location.href = isProduction()
Expand Down

0 comments on commit 4a34667

Please sign in to comment.