-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Bad scrollbar replacement on non-integer width windows #29681
Comments
/CC @Johann-S |
@Johann-S @XhmikosR Thanks a lot for working on this issue! Unfortunately I don't believe the implementation in #30690 solved it just yet. In fact when I debugged the original StackBlitz and injected the rounding from the PR, padding was still applied, although no scrollbar was present to begin with. Concretely, the first setup I came up with had this._isBodyOverflowing = Math.floor(left + right) < window.innerWidth is I'm not sure if const overflowingWidth = window.innerWidth - left - right;
this._isBodyOverflowing = overflowingWidth > 0.5; // or 1? |
@XhmikosR: Of course, thanks for asking! I'll look into it on the weekend. Meanwhile, maybe you can help me understand some of the other edge cases I'm not seeing here. In #30017 you were concerned that rounding up might lead to a wrong result. Do you have a concrete use case in mind for that? Also, I'm not sure for which case substracting |
Can you confirm @kremerd you're able to reproduce it on one of those links please: |
@Johann-S In principal, yes:
Do I understand you correctly, that you're unable to reproduce the issue yourself? If so, are you able to set "Good size!" widths in the Stackblitz demo? What happens if you open the modal then? |
I can actually reproduce now on https://stackblitz.com/edit/bootstrap-scrollbar-handling?file=index.html We need a test case for sure in our unit tests. |
So, the question is, can this cause rounding issues? From my tests it can't. Not sure why I thought it could. Math.round(rect.left + rect.right) < window.innerWidth That being said, we need some help with adding a test case. I will revert the merged patch and reopen the original PR. |
For what is worth, I also reproduced without using zoom. My DPI is 175% so maybe that affects things. |
Bug description:
When a modal is shown on a scrollable page, the scrollbar is hidden and the page body is padded to compensate for the lost width. Depending on display settings and the browsers zoom level, this padding is sometimes applied, even when the page body is not scrollable and there is no scrollbar to begin with.
So far as I can tell this happens, when the value
right = document.body.getBoundingClientRect().right
rounds up, i.e. ifright - Math.floor(right) > 0.5
. You can check it yourself on this demo site (full Stackblitz).Note that in order for the value to be non-integer, the page must be rendered in a non-native resolution. This can be done by zooming in or out of the page, or by scaling the display in system settings like these in Windows.
Tested browsers:
I tested and reproduced this bug on Windows 10 with the following browsers:
Related issues:
As #28101 this issue regards the padding introduced to compensate for scrollbars. While in that issue padding is applied when the scrollbar cannot be hidden, this issue is about padding that is applied when no scrollbar was shown to begin with.
I originally posted this at ng-bootstrap/ng-bootstrap#3448, but now realised that the same issue occurs in the plain Bootstrap implementation as well (and for the same reason).
Suggested fix
Some rounding must be applied in the method _checkScrollbar to accomodate for non-integer values:
This works for the scenarios I tested. Still, I don't understand why
rect.left
is added here, so maybe I'm missing something...The text was updated successfully, but these errors were encountered: