Skip to content

Commit d18dadb

Browse files
committed
[fixed] container content no longer shifts when overflowing
Incorporates upstream tbs logic to pad the container before hiding the scrollbar with the `.modal-open` class fixes react-bootstrap#354
1 parent 66f0f92 commit d18dadb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Modal.js

+8
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ const Modal = React.createClass({
207207

208208
this._containerIsOverflowing = container.scrollHeight > containerClientHeight(container, this);
209209

210+
this._originalPadding = container.style.paddingRight;
211+
212+
if (this._containerIsOverflowing) {
213+
container.style.paddingRight = parseInt(this._originalPadding || 0, 10) + scrollbarSize + 'px';
214+
}
215+
210216
if (this.props.backdrop) {
211217
this.iosClickHack();
212218
}
@@ -237,6 +243,8 @@ const Modal = React.createClass({
237243

238244
let container = getContainer(this);
239245

246+
container.style.paddingRight = this._originalPadding;
247+
240248
container.className = container.className.replace(/ ?modal-open/, '');
241249

242250
this.restoreLastFocus();

0 commit comments

Comments
 (0)