Skip to content

Commit

Permalink
CDPT-1994: TypeError: e().offset is undefined
Browse files Browse the repository at this point in the history
- Check whether the banner exists before getting the offset and top position
  • Loading branch information
EmilyHazlehurst committed Jan 13, 2025
1 parent d9caaa2 commit 53777d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions public/app/themes/justice/src/patch/js/ccfw-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 53777d3

Please sign in to comment.