Repository navigation
Add some violations in a11y inspector - #191994
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates accessibility evaluations into the AccessibilityInspector to append detected accessibility issues, such as tap target size, missing labels, and unlabeled leaf nodes, directly to the JSON representation of semantics nodes. To support this, the traversal methods in several accessibility evaluations were made public. Feedback suggests simplifying the retrieval of the PipelineOwner by utilizing the new _findRenderView helper, which would eliminate the redundant _findPipelineOwner method.
|
|
||
| List<Violation> _traverse(SemanticsNode node) { | ||
| /// Traverses the given [node] and returns all found violations. | ||
| List<Violation> traverse(SemanticsNode node) { |
There was a problem hiding this comment.
we should consider move traverse to base class if this is going to be the entry point of evaluation, I originally created evaluate method as entry point to work with bindings, should remove that if that is not useful.
There was a problem hiding this comment.
added traverse in the base class
| nodes[node.id.toString()] = node.toJson(); | ||
|
|
||
| nodes[node.id.toString()] = <String, Object?>{ | ||
| ...node.toJson(), |
There was a problem hiding this comment.
why expand the map? if we are going to inject other property like issues in line 132, we should probably put node.toJson as a object of its own to avoid property override
| } | ||
|
|
||
| // TODO(hannahjin): This returns the first SemanticsOwner of any RenderView. | ||
| // TODO(hannah-hyj): This returns the first RenderView with a SemanticsOwner. |
There was a problem hiding this comment.
We should file an issue for this
chunhtai
left a comment
There was a problem hiding this comment.
LGTM, except some minor comments
| } | ||
|
|
||
| /// Evaluate whether the current state of the `binding` conforms to the rule. | ||
| FutureOr<EvaluationResult> evaluate(WidgetsBinding binding) { |
There was a problem hiding this comment.
if there is practical use case this method, we should remove it
There was a problem hiding this comment.
Looks like evaluate(binding) is still necessary because evaluations like MinimumTextContrastEvaluation (which asynchronously rasterizes renderView.debugLayer to check pixel contrast) and TitleEvaluation (which inspects the element tree via binding.rootElement) require WidgetsBinding and cannot be implemented as a synchronous traverse(SemanticsNode)."
There was a problem hiding this comment.
Is it possible to have a single entry point for all the guideline? better to keep it unify and abstract.
There was a problem hiding this comment.
updated the PR and removed removed traverse() from the Public API, evaluate() will be the single entry point.
2941209 to
d0870e6
Compare
chunhtai
left a comment
There was a problem hiding this comment.
my latest comment #191994 (comment)
d0870e6 to
174cd00
Compare
|
@chunhtai comment resolved! |
| } | ||
|
|
||
| // The violations are displayed in Devtool. | ||
| // TODO(hannah-hyj): If we add a "target platforms" option on the devtool side, |
There was a problem hiding this comment.
I imagine this should be something set by the devtools instead of hardcoded in framework
There was a problem hiding this comment.
yeah that's why I added a TODO here, should pass the target platform from the devtool
| expect(labeledResult['result'], isEmpty); | ||
| final Map<String, Object?> labeledTapTargetResult = await _runEvaluation( | ||
| tester, | ||
| <String, String>{'type': 'LabeledTapTargetEvaluation'}, |
There was a problem hiding this comment.
This string should be defined somewhere same for other checks
There was a problem hiding this comment.
Added AccessibilityEvaluationType enum and AccessibilityInspectorKeys constants
| final nodeIssues = <int, List<Map<String, Object?>>>{}; | ||
|
|
||
| final evaluations = <(AccessibilityEvaluation, String)>[ | ||
| (MinimumTapTargetEvaluation(size: minSize), 'tapTargetSize'), |
There was a problem hiding this comment.
looks like we will have a bunch of strings. We should define them in somewhere and document how each strings are used.
There was a problem hiding this comment.
Added AccessibilityEvaluationType enum and AccessibilityInspectorKeys constants
5b0c1b0 to
df98f5a
Compare
| @@ -62,17 +92,54 @@ class AccessibilityInspector { | |||
| /// Evaluates and returns the semantics tree hierarchy of the application. | |||
There was a problem hiding this comment.
We probably shouldn't mixing evaluation result with semantics tree. We may have more guideline later on that doesn't tight to semantics tree. for example the TitleEvaluation
There was a problem hiding this comment.
Updated! now it returnes evaluation results under the top-level AccessibilityInspectorKeys.issues key
There was a problem hiding this comment.
I meant should we have two endpoints, one for getting semantics tree only, the other for getting violations? The current endpoint, If one only wants to get semantics tree, they will also have to wait for inspection result even if they don't need it.
There was a problem hiding this comment.
i worry if there're two endpoints , one for getting semantics tree only, one for getting violations only, they may be called in different frames and the results dont match.
I updated it to two endpoints, but one for getting semantics tree only, one for getting tree and violations, wdyt?
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
chunhtai
left a comment
There was a problem hiding this comment.
my latest comment #191994 (comment)
Make the traverse function in [_accessibility_evaluations.dart] public. Add violations in a11y inspector. tracking issue: flutter/devtools#9893 ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [ ] 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]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [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 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Make the traverse function in [_accessibility_evaluations.dart] public.
Add violations in a11y inspector.
tracking issue: flutter/devtools#9893
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.