Skip to content

Conversation

@hannah-hyj
Copy link
Member

@hannah-hyj hannah-hyj commented Feb 29, 2024

  1. Set cacheExtent for sliverAppBar so it's not dropped from the semantics tree.
  2. Update its toolbarOpacity in a11y mode to 1.0. When scrolling in a11y mode and the focus is back to the sliverAppBar, the content should be visible.
    fixes: iOS VoiceOver isn't able to go back to SliverAppBar from SliverSafeArea after appbar leaves screen  #143437

Pre-launch Checklist

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Feb 29, 2024
@hannah-hyj hannah-hyj changed the title Update a11y for sliverAppbar Update a11y for SliverAppBar Feb 29, 2024
@hannah-hyj hannah-hyj requested review from HansMuller and Piinks and removed request for Piinks March 4, 2024 20:49
}
final double maxExtent = this.maxExtent;
final double paintExtent = maxExtent - constraints.scrollOffset;
final double cacheExtent = calculateCacheOffset(
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't claim to understand the API doc for calculateCacheOffset (which is often used to calculate cache extents?) however this statement is troubling: This method is not useful if there is not a 1:1 relationship between consumed scroll offset and consumed cache extent. Presumably that's true for pinned persistent headers, so unconditionally specifying the cache extent here might not be recommended.

@Piinks - WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

The cacheExtent here is of RenderSliverScrollingPersistentHeader, which is a non-pinned and non-floating variant of the sliver app bar. So I think the consumed scroll offset and consumed cache extent is a 1:1 relationship.

The pinned headers you mentioned are RenderSliverPinnedPersistentHeader, it doesn't have an a11y issue because it won't be scrolled off the screen and dropped from the semantics tree.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Hangyujin is right, this is the scrolling render object, not the pinned one.
I think this is the second or third sliver a11y issue that was caused by the cacheExtent not being set like this. It may be worth checking the rest of the sliver library for the same issue in other slivers.

final bool isScrolledUnder = overlapsContent || forceElevated || (pinned && shrinkOffset > maxExtent - minExtent);
final bool isPinnedWithOpacityFade = pinned && floating && bottom != null && extraToolbarHeight == 0.0;
final double toolbarOpacity = !pinned || isPinnedWithOpacityFade
final bool isAccessibilityOn = MediaQuery.of(context).accessibleNavigation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the value of MediaQuery.of(context).accessibleNavigation be a passed parameter so it can be checked in shouldRebuild for when it changes?

Copy link
Member Author

@hannah-hyj hannah-hyj Mar 7, 2024

Choose a reason for hiding this comment

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

Use of MediaQuery.of or MediaQuery.accessibleNavigationOf will cause it to rebuild, is it still necessary to add a parameter to shouldRebuild?

https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/media_query.dart#L1457-L1462

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test that switches accessibleNavigation off and on to verify it updates? Usually I would use didChangeDependencies, but _SliverAppBarDelegate is not a stateful widget.

Copy link
Member Author

Choose a reason for hiding this comment

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

Test added. Looks like I do need to update it to shouldRebuild(), thank you!

}
final double maxExtent = this.maxExtent;
final double paintExtent = maxExtent - constraints.scrollOffset;
final double cacheExtent = calculateCacheOffset(
Copy link
Contributor

Choose a reason for hiding this comment

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

@Hangyujin is right, this is the scrolling render object, not the pinned one.
I think this is the second or third sliver a11y issue that was caused by the cacheExtent not being set like this. It may be worth checking the rest of the sliver library for the same issue in other slivers.

@hannah-hyj hannah-hyj requested a review from Piinks March 7, 2024 00:21
@hannah-hyj
Copy link
Member Author

@Piinks ping for review :)

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! Thank you! 🎉

@hannah-hyj hannah-hyj merged commit 58eb0e8 into flutter:master Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

iOS VoiceOver isn't able to go back to SliverAppBar from SliverSafeArea after appbar leaves screen

3 participants