Skip to content

Conversation

@ash2moon
Copy link
Contributor

@ash2moon ash2moon commented Apr 15, 2025

This pull request replaces the use of the deprecated announce calls with idiomatic Semantic widgets and also removes the extra Feedback.forTap call. The InkWell widget already wraps the onTap with the Feedback.forTap. I also made sure sure that existing functionality is not impacted.

Resolves #166448
Partially addresses #165510

Physical Testing:
Android ✅
iOS ✅
Web ✅

Pre-launch Checklist

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

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Apr 15, 2025
@ash2moon ash2moon marked this pull request as draft April 15, 2025 23:06
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@ash2moon ash2moon force-pushed the fix/wrap-for-tap branch 2 times, most recently from 495ee64 to bfde3c0 Compare April 18, 2025 00:14
@ash2moon ash2moon marked this pull request as ready for review April 18, 2025 00:14
@ash2moon ash2moon requested review from a team, TahaTesser and goderbauer April 18, 2025 00:15
@jmagman
Copy link
Member

jmagman commented Apr 21, 2025

Test failure:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: includes node with label "7:15 AM"
  Actual: SemanticsTester:<SemanticsTester for SemanticsNode#0(Rect.fromLTRB(0.0, 0.0, 2400.0,
1800.0))>
   Which: could not find node with label "7:15 AM".
          Try dumping the semantics with
debugDumpSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest) from the
package:flutter/rendering.dart library to see what the semantics tree looks like.
Header should have semantics label: 7:15 AM (12-hour)

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///b/s/w/ir/x/w/flutter/packages/flutter/test/material/time_picker_test.dart:2279:5)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:193:15)
<asynchronous suspension>
#6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1064:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

This was caught by the test expectation on the following line:
  file:///b/s/w/ir/x/w/flutter/packages/flutter/test/material/time_picker_test.dart line 2279
The test description was:
  provides semantics information for the header (selected time)
════════════════════════════════════════════════════════════════════════════════════════════════════
08:00 +7428 ~12 -1: /b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/adaptive_text_selection_toolbar_test.dart: Can build for editable text from raw parameters (variant: TargetPlatform.macOS)
08:00 +7428 ~12 -1: /b/s/w/ir/x/w/flutter/packages/flutter/test/material/time_picker_test.dart: provides semantics information for the header (selected time) [E]
  Test failed. See exception logs above.
  The test description was: provides semantics information for the header (selected time)

@QuncCccccc once the test is fixed, are you the right person to review this Material time picker change? If not can you recommend a reviewer?

@QuncCccccc
Copy link
Contributor

I can take a look! But I probably will ask @chunhtai for a second review, as he is the accessibility expert! Please let me know when it's ready😊

@QuncCccccc QuncCccccc self-requested a review April 21, 2025 19:55
@ash2moon ash2moon force-pushed the fix/wrap-for-tap branch 2 times, most recently from 179de80 to 1769213 Compare April 21, 2025 20:06
case Orientation.portrait:
return Column(
return Semantics(
key: const ValueKey<String>('time-picker-header-semantics'),
Copy link
Contributor

Choose a reason for hiding this comment

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

we should avoid adding key for testing purposes like this.

If the purpose is to ensure the semantics label is correct in test, you can use find.bySemanticsLabel('your expected label') and findsOneWidget

_TimePickerModel.selectedTimeOf(context),
alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context),
),
child: switch (_TimePickerModel.orientationOf(context)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider store the switch result into a child first for readability

return Column(
return Semantics(
key: const ValueKey<String>('time-picker-header-semantics'),
label: MaterialLocalizations.of(context).formatTimeOfDay(
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 explain a bit why we need a label here, is the previous behavior broken?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because previously we were using _announceInitialTimeOnce to announce this time, but now with a label, it is announced when it is in focus.

switch (widget.hourDialType) {
case _HourDialType.twentyFourHour:
case _HourDialType.twentyFourHourDoubleRing:
_announceToAccessibility(context, localizations.formatDecimal(newTime.hour));
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we remove all the announcement, how do we convey the information to user ? I assume there will be a liveregion somewhere?

Same for other announcements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A lot of these announcements were manually invoked because of the problem with Feedback.wrapForTap resulting in double announcements. Since the root cause was due to InkWell already doing a Feedback.wrapForTap, we did not need the extra wrapper within the on* callbacks. I think because of this, the original author used announce to prevent Talkback from speaking the double announcement and rewriting its responses.

Copy link
Contributor

Choose a reason for hiding this comment

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

If in the course of your investigation you found prs or comments that helped you come to this conclusion please add them as a comment here. If not then please do not spend time tracking it down.

final RenderObjectWidget orientationSpecificHeader = switch (_TimePickerModel.orientationOf(
context,
)) {
Orientation.portrait => Column(
Copy link
Contributor

Choose a reason for hiding this comment

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

It is out of scope for this pr but I really dont like how we are using the device orientation enum value all over this code for what I think is a proxy for OrientationBuilder.

Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

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

Please hold merge until approval from someone on the framework team.

Copy link
Contributor

@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.

LGTM

@ash2moon ash2moon added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Apr 23, 2025
@dkwingsmt
Copy link
Contributor

@ash2moon Is this PR ready for submission?

@ash2moon ash2moon added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 23, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
…ap calls (flutter#167241)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

This pull request replaces the use of the deprecated announce calls with
idiomatic Semantic widgets and also removes the extra `Feedback.forTap`
call. The `InkWell` widget already wraps the onTap with the
`Feedback.forTap`. I also made sure sure that existing functionality is
not impacted.

Resolves flutter#166448
Partially addresses flutter#165510

Physical Testing:
Android ✅
iOS ✅
Web ✅

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
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. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android TalkBack announces previous radio button's unchecked state when tapping a new radio button wrapped in Feedback.wrapForTap

6 participants