From 53777d3ef35dfac5cd4785ed2c5a7e48bd3b072d Mon Sep 17 00:00:00 2001 From: Emily Hazlehurst Date: Mon, 13 Jan 2025 14:22:22 +0000 Subject: [PATCH] CDPT-1994: TypeError: e().offset is undefined - Check whether the banner exists before getting the offset and top position --- .../app/themes/justice/src/patch/js/ccfw-frontend.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/app/themes/justice/src/patch/js/ccfw-frontend.js b/public/app/themes/justice/src/patch/js/ccfw-frontend.js index 6a6d802c..859b8e79 100644 --- a/public/app/themes/justice/src/patch/js/ccfw-frontend.js +++ b/public/app/themes/justice/src/patch/js/ccfw-frontend.js @@ -56,10 +56,13 @@ import { CCFW } from './ccfw-gtm' this.$el.show() this.$cookieSettingsButton.hide() - // the cookie banner is now at the top, so we scroll to the top - $([document.documentElement, document.body]).animate({ - scrollTop: $('#ccfw-page-banner').offset().top - }, 200) + const banner = $('#ccfw-page-banner'); + // If the cookie banner exists, scroll to the top + if (banner.length > 0) { + $([document.documentElement, document.body]).animate({ + scrollTop: banner.offset().top + }, 200) + } }, hideBanner: function () { this.$el.hide()