Skip to content

Commit 3cfef32

Browse files
committed
[material-ui][Modal] Take non-integer padding-right into consideration when scroll locking
1 parent a43a1bb commit 3cfef32

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/mui-material/src/Modal/ModalManager.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,18 @@ describe('ModalManager', () => {
129129
});
130130

131131
it('should handle the scroll', () => {
132-
fixedNode.style.paddingRight = '14px';
132+
fixedNode.style.paddingRight = '14.4px';
133133

134134
const modal = getDummyModal();
135135
modalManager.add(modal, container1);
136136
modalManager.mount(modal, {});
137137
expect(container1.style.overflow).to.equal('hidden');
138138
expect(container1.style.paddingRight).to.equal(`${20 + getScrollbarSize(window)}px`);
139-
expect(fixedNode.style.paddingRight).to.equal(`${14 + getScrollbarSize(window)}px`);
139+
expect(fixedNode.style.paddingRight).to.equal(`${14.4 + getScrollbarSize(window)}px`);
140140
modalManager.remove(modal);
141141
expect(container1.style.overflow).to.equal('');
142142
expect(container1.style.paddingRight).to.equal('20px');
143-
expect(fixedNode.style.paddingRight).to.equal('14px');
143+
expect(fixedNode.style.paddingRight).to.equal('14.4px');
144144
});
145145

146146
it('should disable the scroll even when not overflowing', () => {

packages/mui-material/src/Modal/ModalManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function ariaHidden(element: Element, hide: boolean): void {
2626
}
2727

2828
function getPaddingRight(element: Element): number {
29-
return parseInt(ownerWindow(element).getComputedStyle(element).paddingRight, 10) || 0;
29+
return parseFloat(ownerWindow(element).getComputedStyle(element).paddingRight) || 0;
3030
}
3131

3232
function isAriaHiddenForbiddenOnElement(element: Element): boolean {

0 commit comments

Comments
 (0)