-
Notifications
You must be signed in to change notification settings - Fork 250
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
[SuperEditor][SuperReader] - Lock scrolling when content fits within available space (Resolves #1409) #1421
Conversation
@matthew-carroll Could you please take a look at the approach I took to fix this issue? It's still WIP but wanted your opinion on the approach and see if whether this is the direction that we want to move in with this issue. |
@rutvik110 before evaluating your choice of solution, can you describe what you investigated? For example, why is the scrollable letting us scroll when there's no content to scroll? |
There seems to be two reasons here that are causing the overscroll. The first reason is related to our handling of the scrolling within Second reason is bit more ambiguous and it may be totally different issue that I may've confused with this one but here it's. It seems to be particularly related to usage of Screen.Recording.2023-09-12.at.8.45.55.AM.mov |
@@ -387,6 +387,12 @@ class AutoScrollController with ChangeNotifier { | |||
return; | |||
} | |||
|
|||
// There's no content to scroll. So, we can't go ballistic as it would result |
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.
@matthew-carroll I've reverted the previous additions I made to this issue. I think those additions were targeting a different issue than the one we're trying to solve here.
Wrt the first reason I mentioned above for overscrolling, this update resolves that.
Currently, we do a final scroll call with goBallistic
to animate to a new scroll position at the end of the mouse events(specifically pan events) that results in scrolling the content.
I added a check to prevent making this call if there's no content to scroll to or maxScrollExtent
is 0.
This should take care of the overscroll that was happening when the content fits within the available space.
@@ -50,7 +50,8 @@ class _SwitchDocumentDemoState extends State<SwitchDocumentDemo> { | |||
child: Column( | |||
children: [ | |||
_buildDocSelector(), | |||
Expanded( | |||
IntrinsicHeight( |
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.
Please revert this.
ah yah, had to add the same max extent check to Also, what are your thoughts on the previous comment I made regarding extent check in the reverse direction? |
I think the current changes are probably good as-is. Can you confirm that these changes work for SuperReader as well as SuperEditor? Also, can you write a test for each of these scenarios in the appropriate test file? And please don't forget to revert the code that I mentioned in an earlier comment. |
Great! Will check on |
7e9353d
to
cf930f8
Compare
|
||
group("doesn't scroll editor when content fits within the available space", () { | ||
testWidgetsOnDesktop( | ||
"attempts to scroll editor vertically in both directions using trackpad", |
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.
These test names aren't great. Look at what the final test name is:
"doesn't scroll editor when content fits within the available space attempts to scroll editor vertically in both directions using trackpad"
I think you can describe the group and test in a way that's much more concise, and makes sense when read as the final test description.
super_editor/test/super_reader/super_reader_scrolling_test.dart
Outdated
Show resolved
Hide resolved
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.
LGTM
…available space (Resolves superlistapp#1409) (superlistapp#1421)
[SuperEditor][SuperReader] - Lock scrolling when content fits within available space (Resolves #1409)
Currently in the
SuperEditor
orSuperReader
, the document is scrollable even if the content fits within the available space as seen in the below demo.This demo wraps the
SuperEditor
within anIntrinsicHeight
widget to demonstrate the issue,Screen.Recording.2023-09-07.at.1.02.09.PM.mov
This PR tries to address this issue by locking the scrolling for the document in such cases. We lock the scrolling when the content of the document fits within the available viewport space and there isn't any unconsumed content within the
Scrollable
.Scroll lock is introduced within both
DocumentScroller
andAutoScrollController
. When the scroll lock is enabled, any calls/actions related to scrolling are ignored to prevent the document from scrolling.After this latest updates, the scrolling is locked whenever content fits within available space as seen in the following demo,
f_scroll_lock.mp4