Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double scrollbars for flexbox parents #488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gittenburg
Copy link

@Gittenburg Gittenburg commented Jun 26, 2020

Fixes #473.

@Gittenburg Gittenburg changed the title Add support for flexbox parents (fix #473) Add support for flexbox parents Jun 26, 2020
@Grsmto
Copy link
Owner

Grsmto commented Jul 3, 2020

Hi!
Thanks very much for your contribution.

Could you hold on with this quick fix until the next major release?
Merging this PR in the current state would probably generate unexpected behaviour in other scenarios, since as you noticed applying overflow: hidden would break the overflow settings detection (what if I want a flex layout with X axis scrolling only?).
So I would rather include the fix for this on the next major release (as there will be breaking changes anyways...).

Also applying height: 100% on the host element should also workaround this issue, (same way as overflow: hidden).

Quick note but I think there is something wrong with your "broken" example: if you remove simplebar from that example, it will do exactly the same. It's normal CSS behaviour, the child of the flex container is overflowing its parent, so there isn't any scrollbar unless you define overflow: auto.

Thanks!

@Gittenburg Gittenburg force-pushed the flexbox branch 3 times, most recently from 98721b9 to e8af63a Compare July 6, 2020 06:35
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.
@Gittenburg
Copy link
Author

Gittenburg commented Jul 6, 2020

Hi, thanks for the detailed reply!

I couldn't get height: 100% to work previously but I must have been doing something wrong as it works flawlessly.

Quick note but I think there is something wrong with your "broken" example: if you remove simplebar from that example, it will do exactly the same. It's normal CSS behaviour, the child of the flex container is overflowing its parent, so there isn't any scrollbar unless you define overflow: auto.

You are correct that if you remove simplebar from the example the behaviour doesn't change. Note however that Simplebar does not follow normal CSS behaviour: when you specify a height on the host element it makes the content scrollable, even if you do not specify overflow: auto.

I updated this PR to just be a one-line CSS addition: setting max-height: 100% for [data-simplebar]. That fixes the double scrollbar bug #473 and should not break existing uses (you can still override the height or the overflow behaviour).

@Gittenburg Gittenburg changed the title Add support for flexbox parents Prevent double scrollbars for flexbox parents Jul 6, 2020
@andrskr
Copy link

andrskr commented Nov 16, 2020

@Grsmto I may not understand something but in order for flexbox styles to work you need to add display: flex; here

flex-direction: column;
This helped me solve the problem with double scrollbars (in my case, just all by adding my own className with overflow: auto; to the SimpleBar React Component and apply overflow: hidden; to parent element)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flexbox item double sidebar
3 participants