-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Fixed Scroll bars incorrectly rendering with view padding #150685
Conversation
653ef4d
to
5e13139
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @D-extremity thanks for contributing! There are some failing tests here, can you take a look?
yeah! actually When padding is removed from RawScrollbar, Material Scrollbar and Cupertino, i wrote test cases they are passed, but previous tests started failing because when they were written, they were written with the idea of padding in the scrollbar, i fixed some. I am trying to solve this test case error, it would be helpful if you have any tip or idea to solve it
|
That one looks like a precision error. The values of the rect are not precisely matching the expectation, so I would update the test to check the individual values of the rect using the |
0403640
to
81a73e6
Compare
@Piinks please review it in your available time |
Mostly ok except for the removed expect |
Thank you sir, |
31c0020
to
0039cfb
Compare
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
fixed formatting Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
fixed formatting Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
32cc7b5
to
9183442
Compare
f9b98b6
to
51845be
Compare
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
I did some more investigation on the failed test (https://github.com/flutter/flutter/pull/150685/files#diff-c470a64409840da3df5f8b241a8b984964dd26290c65839c8ebeddcc16691155L118) and tried to get the exact number and how it is made up. The correct height is
The fractionVisible is a result of
Compare with before the PR, where
To my understanding, what we want to do is merely to change how the scrollbar is painted, not the content, therefore I'm surprised to find that @Piinks May I have your opinion? |
Woo!! It worked ❤️ |
Yeah, but I'm still concerned whether it's the correct way to go. Let's get her opinion first (she's probably OOO for a few days.) |
), | ||
)); | ||
expect(tester.getRect(find.byType(CupertinoScrollbar)), | ||
rectMoreOrLessEquals(const Rect.fromLTWH(0, 0, 800, 600), epsilon: 1)); // (800, 600) is viewport size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look right, does the scrollbar overlap the navigation bar now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What iOS does is that, if the scrollbar is full screen, then the scrollbar follows the safe area. If the scrollbar is attached to a non-fullscreen widget, such as a card, then the scrollbar shouldn't have any paddings.
So the problem is, either we have a way for the scrollbar to automatically detect what it is attached to, or its parent should be responsible to decide whether the scrollbar should use the view padding.
For the first option, if we decide that it's the parent's responsibility to warp itself in SafeArea
, then we don't need this PR at all. However I don't think this is a good way, because we have way more "non-fullscreen" widgets than fullscreen widgets.
Therefore I'm basically proposing that the scrollbar should by default assume it's attached to a non-fullscreen widget, and the parent should explicitly apply view padding to the scrollbar if the parent knows itself is fullscreen.
And in this way, in case the scrollbar is used without any further indication (such as in this unit test), yes, the scrollbar overlaps the navigation bar. The unit test's behavior is expected, although the widget in the unit test is written in a discoraged way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the parent should explicitly apply view padding to the scrollbar if the parent knows itself is fullscreen.
Wouldn't this be a breaking change then?
yes, the scrollbar overlaps the navigation bar.
As a user I would not expect this, especially since on some platforms, the scrollbar is added automatically and the user does not have as much control over it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we can also add a paragraph to the doc to notify the user of the default padding, and suggest them to either use a SafeArea or pass in a zero padding in non-fullscreen cases. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we can also add a paragraph to the doc to notify the user of the default padding, and suggest them to either use a SafeArea or pass in a zero padding in non-fullscreen cases. What do you think?
I was thinking if we provide padding from top equal to kToolBarHeight
and from bottom also kToolBarHeight
only when bottom navigation bar and app bar is enabled for that Widget, else padding remains 0.
I might be wrong this is just an idea which i think might work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users already expect that to work though without having to manually configure it. 🤔
Another more complicated solution is to detect the boundary of the Scrollbar widget in terms of screen space, and calculate the padding it needs to use dynamically. For example, if there's scrollbar is on a card that is 10 px within the edge of the screen, then the padding of the scrollbar will be viewPadding-10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should take a step back, maybe I have lost sight of the root issue. The scrollbar determines its bounds based on the child it wraps, which is usually the viewport (the window scrolling is happening in).
When I look at the video in the OP of the issue, I think oh yeah that padding should totally be removed so the notch of the phone does not affect the scrollbar in the dialog. Then I realized, shouldn't the dialog handle that then? The dialog has consumed the view padding. Should the dialog remove the padding then? Scaffold does this, it removes the padding as it's children consume it, like with AppBar and BottomNavigationBar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm mostly thinking that the current default is counterintuitive, since I would consider full screen scrollbars rarer than non fullscreen ones. But I agree that we don't have to change it, but if we don't I think we should improve the doc to explain it. It surprised me when I worked on it and I don't even know which parameter to turn it off, and it took me a while to realize that the scrollbar padding equals to view padding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Piinks How do you think we should move on? Should we improve the doc instead (or should we at all?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you think we should move on?
If we can update this change to not have the overlap of the navigation bar by default, that would be a path forward. Right now as it is, it is a significant breaking change.
That part looks to be expected with this change, since the padding was used to compute _totalTrackMainAxisOffsets, which goes into the calculation of fractionVisible. |
Caught up with @dkwingsmt, this is not a change we think we want to make right now, so we are going to close this for now. Thank you @D-extremity for contributing! |
Replacing
..padding = MediaQuery.paddingOf(context)
with..padding = widget.padding??EdgeInsets.zero
to fix incorrect rendering of scrollbar.closes #150544
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on [Discord].