Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(a11y): check for remaining relevant text direction properties #165028

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

Conversation

Goddchen
Copy link
Contributor

@Goddchen Goddchen commented Mar 12, 2025

We faced an issue that the assert at https://github.com/flutter/flutter/blob/3.29.1/packages/flutter/lib/src/semantics/semantics.dart#L497-L500 was triggering although our widget was placed under a MaterialApp and therefore had a text direction set.

Turns out that _getTextDirection() just was not checking for attributedValue, etc.

Related issue: #165051
fixes #165051

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 the framework flutter/packages/flutter repository. See also f: labels. label Mar 12, 2025
@lColinDl
Copy link

Here's a standalone test to reproduce the bug and verify that it's fixed:

testWidgets('semantics with attributed value should not fail',
    (tester) async {
  await tester.pumpWidget(
    MaterialApp(
      home: Semantics(
        attributedValue: AttributedString('test value'),
        child: const Placeholder(),
      ),
    ),
  );
});

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

@Goddchen Sorry for the late review here. Thanks for fixing this.

Can you add a test? @lColinDl has a good suggestion in #165028 (comment). I would just add this to the bottom I think: expect(tester.takeException(), isNull);.

@Goddchen
Copy link
Contributor Author

@justinmc done ✅
Not sure what is up with that failing Linux build_tests_2_5 job. It fails while downloading Gradle 🤷‍♂️ Do you have any idea?

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

I've rerun that failing test, looks like an infrastructure failure. I'll try to find a secondary reviewer.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

LGTM, but one small suggestion.

Comment on lines 7569 to 7579
properties.attributedLabel != null ||
properties.label != null ||
properties.attributedDecreasedValue != null ||
properties.attributedIncreasedValue != null ||
properties.attributedValue != null ||
properties.decreasedValue != null ||
properties.increasedValue != null ||
properties.value != null ||
properties.attributedHint != null ||
properties.hint != null ||
properties.tooltip != null;
Copy link
Member

@gnprice gnprice Apr 25, 2025

Choose a reason for hiding this comment

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

I'm thinking about how to help make this more easily kept in sync in the future. I think a useful tactic would be to list these fields in the same order as they're declared on SemanticsProperties:

image

That'd help make it easy to compare this code to that list by eye and check if anything's missing. Conveniently it's also an order that has a nice internal consistency to it: all in pairs foo then attributedFoo (except the one outlier tooltip).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gnprice done in f9ef22a

@Goddchen
Copy link
Contributor Author

Absolutely no clue why these 2 jobs failed, any ideas @gnprice @justinmc ?

@gnprice
Copy link
Member

gnprice commented Apr 25, 2025

One failure is:

tree-status — Tree is currently broken. Please do not merge this PR unless it contains a fix for the tree.

So that means there's a problem unrelated to this PR. There's a few more words on "tree status" here:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#introduction

That one will automatically go green when the tree gets fixed, so there's nothing you need to do.


The other is Google testing. More about that here:
https://github.com/flutter/flutter/blob/master/docs/infra/Understanding-Google-Testing.md

You'll need a Google employee to investigate that one — so that means @justinmc :-)

@Goddchen
Copy link
Contributor Author

thanks for the clarification. The tree status job is green again. @justinmc can you check on the "Google testing" job? Or can I do anything there?

@justinmc
Copy link
Contributor

Looks like the Google test failure was a timeout? Hopefully just that. I've rerun it.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 2025
@auto-submit auto-submit bot added this pull request to the merge queue May 1, 2025
Merged via the queue into flutter:master with commit a794b98 May 1, 2025
75 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 1, 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 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A11y: textDirection not set correctly when using attributedXY parameters
5 participants