fix(docs): [search] fix navigate error when enter pressed (#11718)

This commit is contained in:
wonderl17
2023-02-24 18:04:36 +08:00
committed by GitHub
parent 8280a0b322
commit be9ef049f9

View File

@@ -72,19 +72,19 @@ function initialize(userOptions: any) {
// }),
navigator: {
navigate: ({ suggestionUrl }: { suggestionUrl: string }) => {
navigate: ({ itemUrl }: { itemUrl: string }) => {
if (!isClient) return
const { pathname: hitPathname } = new URL(
window.location.origin + suggestionUrl
window.location.origin + itemUrl
)
// Router doesn't handle same-page navigation so we use the native
// browser location API for anchor navigation
if (route.path === hitPathname) {
window.location.assign(window.location.origin + suggestionUrl)
window.location.assign(window.location.origin + itemUrl)
} else {
router.go(suggestionUrl)
router.go(itemUrl)
}
},
},