Skip to content

Commit 7e513cc

Browse files
authored
fix(Overlay): should clean paddingRight when dialog disappears
1 parent c0f7592 commit 7e513cc

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/overlay/overlay.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ class Overlay extends Component {
507507
const style = {
508508
overflow: bodyOverflow,
509509
};
510-
if (hasScroll()) {
510+
if (bodyPaddingRight !== undefined) {
511511
style.paddingRight = bodyPaddingRight;
512512
}
513513

test/overlay/index-spec.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ const { hasClass } = dom;
1919
const { Popup } = Overlay;
2020
const delay = time => new Promise(resolve => setTimeout(resolve, time));
2121
const scrollbarWidth = dom.scrollbar().width;
22-
const hasScroll = () => {
23-
const doc = document.documentElement;
24-
return doc.scrollHeight > doc.clientHeight && scrollbarWidth > 0;
25-
};
2622

2723
const render = element => {
2824
let inc;
@@ -77,7 +73,7 @@ class OverlayControlDemo extends React.Component {
7773
const { children, ...others } = this.props;
7874

7975
return (
80-
<div>
76+
<div style={{ height: '110vh' }}>
8177
<button
8278
onClick={this.onClick}
8379
ref={ref => {
@@ -364,16 +360,12 @@ describe('Overlay', () => {
364360

365361
simulateEvent.simulate(btn, 'click');
366362
assert(document.body.style.overflowY === 'hidden');
367-
if (hasScroll()) {
368-
assert(document.body.style.paddingRight === `${scrollbarWidth}px`);
369-
}
363+
assert(document.body.style.paddingRight === `${scrollbarWidth}px`);
370364

371365
simulateEvent.simulate(btn, 'click');
372366
yield delay(500);
373367
assert(!document.body.style.overflowY);
374-
if (hasScroll()) {
375-
assert(!document.body.style.paddingRight);
376-
}
368+
assert(!document.body.style.paddingRight);
377369
});
378370
});
379371

0 commit comments

Comments
 (0)