From 626a54dd445db6fd5d73b24c5a70cd5ac0d446d2 Mon Sep 17 00:00:00 2001 From: zonemeen Date: Mon, 8 Aug 2022 10:31:41 +0800 Subject: [PATCH 1/2] fix: click on the docSearch hit action button without jumping link --- src/client/app/router.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index b81fd5fd23a..3ff4775df7b 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -130,6 +130,11 @@ export function createRouter( window.addEventListener( 'click', (e) => { + // don't jump links when click on the docSearch hit action button + const docSearchButton = (e.target as Element).closest( + '.DocSearch-Hit-action-button' + ) + if (docSearchButton) return const link = (e.target as Element).closest('a') if (link) { const { href, origin, pathname, hash, search, target } = link From f2b719ac025e3e5cea9570386acef7253e427185 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Wed, 31 Aug 2022 08:34:17 +0530 Subject: [PATCH 2/2] chore: handle all buttons --- src/client/app/router.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 3ff4775df7b..0f3aac70137 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -130,11 +130,10 @@ export function createRouter( window.addEventListener( 'click', (e) => { - // don't jump links when click on the docSearch hit action button - const docSearchButton = (e.target as Element).closest( - '.DocSearch-Hit-action-button' - ) - if (docSearchButton) return + // temporary fix for docsearch action buttons + const button = (e.target as Element).closest('button') + if (button) return + const link = (e.target as Element).closest('a') if (link) { const { href, origin, pathname, hash, search, target } = link