From 061cfa5eca841fa2126fbb7c36095ce4cdbb960e Mon Sep 17 00:00:00 2001 From: tomoam <29677552+tomoam@users.noreply.github.com> Date: Fri, 19 May 2023 23:11:59 +0900 Subject: [PATCH] fix: handling of a link to redirect URL --- content/tutorial/common/src/__client.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/content/tutorial/common/src/__client.js b/content/tutorial/common/src/__client.js index 06d49d7b4..2aba31a3c 100644 --- a/content/tutorial/common/src/__client.js +++ b/content/tutorial/common/src/__client.js @@ -49,6 +49,8 @@ window.addEventListener('focusin', (e) => { post({ type: 'iframe_took_focus' }); }); +let previous_href = location.href; + window.addEventListener('click', (e) => { let node = e.target; while (node) { @@ -60,7 +62,10 @@ window.addEventListener('click', (e) => { e.preventDefault(); window.open(url, '_blank'); } else { - update_path(url.pathname + url.search + url.hash); + if (location.href !== url.href) { + previous_href = url.href; + update_path(url.pathname + url.search + url.hash); + } } } node = node.parent; @@ -75,8 +80,6 @@ window.addEventListener('visibilitychange', () => { } }); -let previous_href = location.href; - const url_observer = new MutationObserver(() => { if (location.href !== previous_href) { previous_href = location.href;