Skip to content

Conversation

@snat-s
Copy link
Contributor

@snat-s snat-s commented Aug 1, 2022

Added a conditional to check if there is a controller in use so that it can change to the current index of the Tabs.

Before:

149877992-29cb4812-667a-48cc-9272-06179df87d3f.mov

Now:

Screen.Recording.2022-08-01.at.15.39.23.mov

Fixes #96718

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@snat-s snat-s requested review from Piinks and goderbauer August 1, 2022 20:41
@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 1, 2022
@Piinks Piinks added f: scrolling Viewports, list views, slivers, etc. a: quality A truly polished experience labels Aug 1, 2022
@goderbauer
Copy link
Member

@snat-s Looks like the analyzer is unhappy with this change. Can you take a look and fix it up? Thanks!

@goderbauer
Copy link
Member

In the "after" video it actually looks like there is a strange bounce effect when scrolling all the way to the right. Is that expected?

@Piinks
Copy link
Contributor

Piinks commented Aug 2, 2022

In the "after" video it actually looks like there is a strange bounce effect when scrolling all the way to the right. Is that expected?

It is. Since it is on an iOS emulator, the mouse pointer is being treated like a touch drag.

@goderbauer
Copy link
Member

It is. Since it is on an iOS emulator, the mouse pointer is being treated like a touch drag.

I meant the bounce after the autoscroll. Not the one we see when it is actually dragged with the mouse.

@snat-s
Copy link
Contributor Author

snat-s commented Aug 4, 2022

This is another video, it seems like the physics behave differently in group 1 and in group 2.

Screen.Recording.2022-08-04.at.11.48.27.mov

@chunhtai chunhtai self-requested a review August 12, 2022 19:35
@chunhtai
Copy link
Contributor

This is another video, it seems like the physics behave differently in group 1 and in group 2.

Screen.Recording.2022-08-04.at.11.48.27.mov

The scroll doesn't seem to scroll to the end which is a bit weird. Is that expected?

await tester.tap(find.text('Group 2'));
await tester.pumpAndSettle();

// Now that we are in the second group drag to the end and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid we

void initState() {
super.initState();

for (int i = 0; i < 5; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 5? It looks like for this test you only need 2?

_currentIndex = _controller!.index;

if (widget.isScrollable && _scrollController != null) {
_scrollToCurrentIndex();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I have found why the bounce @goderbauer noticed is happening.

Screen.Recording.2022-08-17.at.3.13.35.PM.mov

It is much more noticeable if you make one of the lists of tabs much longer than the other one, shown above.

You may be missing a setState call before calling _scrollToIndex, that may be a good place to look first here. What it looks like is that:

in LongTab, the last index is say 100 pixels away.
in the shorter tab, the last index is closer, maybe 50 pixels away.

When the index changes here and you call _scrollToIndex, it is using the information from the long tab, rather than the shorter tab. This is why there is a large bounce in the video, it is trying to scroll much further than it needs to.

@Piinks
Copy link
Contributor

Piinks commented Sep 23, 2022

Hey @snat-s did you want to continue with this change? If not that's ok, we can close it for another contributor to look into. :)

@snat-s
Copy link
Contributor Author

snat-s commented Oct 3, 2022

Ohh Hi! I think I am a bit occupied with Uni right now so if any other contributor could help would be better!

@Piinks
Copy link
Contributor

Piinks commented Oct 3, 2022

Ok, no worries at all. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: quality A truly polished experience f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TabBar doesn't scroll to current index when controller changed

4 participants