Repository navigation
fix: horizontally align combo-box overlay - #2153
Conversation
|
|
||
| _shouldAlignLeft(targetRect) { | ||
| const spaceRight = | ||
| (window.innerWidth - targetRect.right - Math.min(document.body.scrollLeft, 0)) / window.innerWidth; |
There was a problem hiding this comment.
Kind of curious why this tries to subtract negative scroll positions?
First, how do you get a negative scroll position? I can only image rubber banding on iOS / Mac, but I can't image how that would be relevant here. Tried with Chrome, FF, Safari, they all report 0 even when doing rubber banding. Also there is no horizontal rubber banding I think?
Second, bounding client rect already accounts for scrolling by reporting the positions relative to the viewport, so whatever the scroll value is, it has already been subtracted from the rect.
There was a problem hiding this comment.
@sissbruecker Seems there is the case when scrollLeft takes a negative value:
If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position (at the start of the scrolled content), and then increasingly negative as you scroll towards the end of the content.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
There was a problem hiding this comment.
...if this is the case, it might be worth creating another test case to cover direction=rtl.
There was a problem hiding this comment.
OK thanks, that would explain how it can assume a negative value.
However I'm still sceptical of the logic, as bounding client rect should already compensate for the scroll position: https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#value
I might just have to test this, I'm having a hard time visualising this.
There was a problem hiding this comment.
It turns out that it's not required to cover the rtl case. Removed.
|
Kudos, SonarCloud Quality Gate passed!
|
Fixes #411