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

getScrollBarWidth occasionally returns 100 when failing to calculate the width via clientWidth #123

Closed
yagottahavehart opened this issue Oct 10, 2019 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@yagottahavehart
Copy link

What is the current behavior?
New implementation of getScrollWidth causing occasional issues resulting in a margin-right of -100 set to the scrollbar, when something around 15-20 would be appropriate.

Steps to reproduce/debugging/Suggestions
Unfortunately, we've noticed this deep in our site & don't have a reliable way to reproduce it. The content in question is located within an iFrame and the though is that the width calculations are happening before it's fully mounted.

I believe it's related to the change in Commit: 543bbd4

Specifically, scrollbarWidth = el.offsetWidth - el.clientWidth; was replaced with getScrollbarWidth._cache = 100 - el.clientWidth; in this commit.

When stepping through, el.clientWidth occasionally returns 0 (instead of the expected 80/85), which worked previously because el.offsetWidth returned 0 as well, resulting in the fallback width of 20.

Note: putting a breakpoint after the doc.body.appendChild(el) gives the site enough time to load & the correct value is returned from el.clientWidth

Not sure the correct solution here to harden the automatic getScrollbarWidth, but a value of 0 for el.clientWidth does not seem like it should be respected and perhaps should result in the fallback

A little about versions:

  • OS: OSX 10.14.5 (18F132) (though have seen it across a couple versions)

  • Browser (vendor and version): Chrome Version 77.0.3865.90 (Official Build) (64-bit)

  • React: 16.10.1

  • react-scrollbars-custom: 4.0.20

  • Did this worked in the previous package version? Yes, 4.0.18

@xobotyi
Copy link
Owner

xobotyi commented Oct 13, 2019

Weird =/ ill add a fallback for that case.
Ty for bugreport.

@xobotyi xobotyi self-assigned this Oct 13, 2019
@xobotyi xobotyi added the bug Something isn't working label Oct 13, 2019
@yagottahavehart
Copy link
Author

Thank you!

@xobotyi
Copy link
Owner

xobotyi commented Oct 13, 2019

@yagottahavehart write here on any results pls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants