From bdb47fc0c479c7845748c8f5a137e4a343e8bd69 Mon Sep 17 00:00:00 2001 From: David Featherston Date: Thu, 17 Aug 2023 11:31:40 +1000 Subject: [PATCH] fix(@dpc-sdp/ripple-nuxt-tide): fix pages breaking when numbers are used at the start of an in page nav item (#1310) Co-authored-by: David Featherston --- packages/ripple-nuxt-tide/lib/layouts/default.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ripple-nuxt-tide/lib/layouts/default.vue b/packages/ripple-nuxt-tide/lib/layouts/default.vue index 9069ac673..cdf0cc7b1 100644 --- a/packages/ripple-nuxt-tide/lib/layouts/default.vue +++ b/packages/ripple-nuxt-tide/lib/layouts/default.vue @@ -129,7 +129,9 @@ export default { this.announcerTitle = `Page loading` }, anchorScrollFix (hashbang) { - const elmnt = document.querySelector(hashbang) + // Hashes can start with a number "#2-item" making them invalid, so we need to use an attribute selector + const idSelector = `[id="${hashbang.replace('#', '')}"]` + const elmnt = document.querySelector(idSelector) if (elmnt) { elmnt.scrollIntoView() }