Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Jul 26, 2021

The scrollable needs to know if the content dimensions in the scroll position has changed in order to update its semantics node correctly. This pr adds an API to ScrollingContext to listen to the change.

fixes #40419

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 feature I am adding, or Hixie said the 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.

@flutter-dashboard flutter-dashboard bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels Jul 26, 2021
@google-cla google-cla bot added the cla: yes label Jul 26, 2021
@chunhtai chunhtai requested review from Piinks and goderbauer July 26, 2021 23:47
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

This looks similar to some of #85499, what do you think @chunhtai?

@chunhtai
Copy link
Contributor Author

chunhtai commented Jul 27, 2021

This looks similar to some of #85499, what do you think @chunhtai?

I think i can make use of the scroll notification to do the job, but I more toward to add this as a call back because the scrollable is strictly tied to a scroll position and not any arbitrary scroll position below its widget sub tree, plus there is one frame delay for it

If the strategy is to avoid adding new api to scroll context and use notification system when it is possible. I can switch to use the notification instead

@Piinks
Copy link
Contributor

Piinks commented Jul 29, 2021

#85499 landed, do you need to update here @chunhtai? Or is this ready for review as is? What do you think?

@chunhtai
Copy link
Contributor Author

I think we still have to figure out whether to add the new api or use the scrollmetrics notification, I currently more toward adding the api See my previous comment.

Piinks
Piinks previously approved these changes Jul 30, 2021
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Flutter_LGTM
with doc nit :)

Comment on lines 64 to 65
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just add documentation for ScrollMetricsNotification here and vice versa - add documentation for this in ScrollMetricsNotification. I think having two separate APIs is ok, because they have very different uses. We may want to also say when they may be preferred, like if you want to listen for this change, choose the other one.

Copy link
Member

Choose a reason for hiding this comment

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

I'm just a little worried, because this api will be called in the layout stage, which will greatly restrict the application scenario, such as the tree cannot be rebuilt, and in the case of lazy loading, it will be called multiple times in the same frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is actually a good point, let me think about this more

@Piinks Piinks dismissed their stale review July 30, 2021 22:34

Will review again after potential updates

Copy link
Contributor Author

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

updated to use notification, PTAL @Piinks @xu-baolin

Copy link
Contributor Author

@chunhtai chunhtai Jul 30, 2021

Choose a reason for hiding this comment

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

@xu-baolin @Piinks
any reason we don't want to send when it initialize for the first time?

My use case here is the render object listens to the scrollable metrics before it applies content dimensions for the first time, it wants to be notified when the scrollable metrics initialize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this doesn't make sense, we probably need a hook, something like didInitializeScrollMetrics

Copy link
Member

Choose a reason for hiding this comment

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

There is no special reason, it's just that we didn't find the necessary scene at the time. If you need it, I think we can do it.

Copy link
Member

Choose a reason for hiding this comment

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

I post #87421 to land this change.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should check the depth of the events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah I see what you meant

Copy link
Member

Choose a reason for hiding this comment

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

Oh,you already checked the context, I think it have the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think use depth is safer since another scrolling context can target the same notification context, that is a weird case if that happens though

Copy link
Member

Choose a reason for hiding this comment

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

This is intended change, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, now it takes one more frame to update the semantics

Copy link
Member

Choose a reason for hiding this comment

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

You just need updates the semantics at the first initial metrics?

Copy link
Contributor Author

@chunhtai chunhtai Jul 31, 2021

Choose a reason for hiding this comment

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

no and subsequence changes as well, we just lucky that scroll metrics change usually come with scroll position changes (which will usuaully cause semantics update) so it wasn't so obvious before.

without the this pr, the semantics for the first frame is always wrong, but we are lucky that usually gets update due to some other semantics changes from the modal route.

Copy link
Member

Choose a reason for hiding this comment

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

Got it.thanks for your explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Piinks Since now the first scroll metrics initialize will call fadeoutanimationcontroller.forward(), the error may throw multiple times

Copy link
Member

Choose a reason for hiding this comment

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

We probably won't need the first empty scroll event request now.

@chunhtai
Copy link
Contributor Author

chunhtai commented Aug 2, 2021

@chunhtai
Copy link
Contributor Author

chunhtai commented Aug 3, 2021

@Piinks @xu-baolin PTAL 🍡

@Piinks
Copy link
Contributor

Piinks commented Aug 3, 2021

Just waiting on the scroll metrics change to roll, there were some failing tests but I think I have them all fixed. Also, CI is unhappy here.

@xu-baolin
Copy link
Member

Just waiting on the scroll metrics change to roll, there were some failing tests but I think I have them all fixed. Also, CI is unhappy here.

Thanks 😄

@Piinks Piinks added the f: scrolling Viewports, list views, slivers, etc. label Aug 11, 2021
@goderbauer
Copy link
Member

Update: we are still waiting on the scroll metrics PR to roll.

@Piinks Piinks added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Aug 17, 2021
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

LGTM!

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

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: tests "flutter test", flutter_test, or one of our tests 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.

ListView: Talkback can't reach offscreen elements if a view is pushed and then popped

5 participants