From 056216a3bd2fd1f28ba9ec6f2797aa2aaec5c6f0 Mon Sep 17 00:00:00 2001 From: Muhammadamin Date: Tue, 23 Feb 2021 07:52:09 -0500 Subject: modal: don't add margin & padding when sticky is not full width (#30621) * modal: don't add margin & padding when sticky is not full width * Check if element is shorter than window Co-authored-by: XhmikosR Co-authored-by: Rohit Sharma --- js/src/modal.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index 4f42e733e..5afb9791b 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -466,6 +466,10 @@ class Modal extends BaseComponent { _setElementAttributes(selector, styleProp, callback) { SelectorEngine.find(selector) .forEach(element => { + if (element !== document.body && window.innerWidth > element.clientWidth + this._scrollbarWidth) { + return + } + const actualValue = element.style[styleProp] const calculatedValue = window.getComputedStyle(element)[styleProp] Manipulator.setDataAttribute(element, styleProp, actualValue) -- cgit v1.2.3