diff --git a/lib/web/mage/calendar.js b/lib/web/mage/calendar.js index 2ed4de71f3f40..b7efe8424b365 100644 --- a/lib/web/mage/calendar.js +++ b/lib/web/mage/calendar.js @@ -1,6 +1,6 @@ /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * Copyright 2025 Adobe + * All Rights Reserved. */ /*eslint max-depth: 0*/ @@ -104,9 +104,15 @@ define([ _overwriteFindPos: function () { $.datepicker.constructor.prototype._findPos = function (obj) { - let domPosition = obj.getBoundingClientRect(); - - return [domPosition.left, domPosition.top]; + var rect = obj.getBoundingClientRect(), + docEl = document.documentElement, + left = rect.left + (window.pageXOffset || docEl.scrollLeft || 0), + top = rect.top + (window.pageYOffset || docEl.scrollTop || 0); + + if (!obj || typeof obj.getBoundingClientRect !== 'function') { + return [0, 0]; + } + return [left, top]; }; },