Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: link error when use keyboard to enter search result #1090

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading