Skip to content

Commit

Permalink
Prevent double scrollbars for flexbox parents
Browse files Browse the repository at this point in the history
Previously attempting to use SimpleBar in a parent with "display: flex"
without specifying a height or "overflow: hidden" on the host element,
resulted in two scroll bars being displayed SimpleBar and the native one.

Fixes Grsmto#473.
  • Loading branch information
Gittenburg committed Jul 6, 2020
1 parent 3f66285 commit e8af63a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/simplebar/src/simplebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export default class SimpleBar {

SimpleBar.getRtlHelpers = memoize(SimpleBar.getRtlHelpers);

const elWindow = getElementWindow(this.el);
const elOverflowY = elWindow.getComputedStyle(this.el).overflowY;
const parentDisplay = elWindow.getComputedStyle(this.el.parentElement).display;
if ((elOverflowY == 'auto' || elOverflowY == 'scroll')
&& (parentDisplay == 'flex' || parentDisplay == 'inline-flex')) {
// Prevent bug where Simplebar is shown along with the native scrollbar.
this.el.style.height = '100%';
}
this.init();
}

Expand Down

0 comments on commit e8af63a

Please sign in to comment.