MinimumTextContrastGuideline should exclude disabled component (#94489)

This commit is contained in:
chunhtai 2021-12-01 20:19:02 -08:00 committed by GitHub
parent bccc9eaca7
commit 049ea73c4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View file

@ -212,7 +212,10 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
Future<Evaluation> evaluateNode(SemanticsNode node) async {
Evaluation result = const Evaluation.pass();
if (node.isInvisible || node.isMergedIntoParent || node.hasFlag(ui.SemanticsFlag.isHidden))
if (node.isInvisible ||
node.isMergedIntoParent ||
node.hasFlag(ui.SemanticsFlag.isHidden) ||
(node.hasFlag(ui.SemanticsFlag.hasEnabledState) && !node.hasFlag(ui.SemanticsFlag.isEnabled)))
return result;
final SemanticsData data = node.getSemanticsData();
final List<SemanticsNode> children = <SemanticsNode>[];

View file

@ -177,6 +177,29 @@ void main() {
expect(result.passed, true);
handle.dispose();
});
testWidgets('Disabled button is excluded from text contrast guideline', (WidgetTester tester) async {
// Regression test https://github.com/flutter/flutter/issues/94428
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
_boilerplate(
ElevatedButton(
onPressed: null,
child: Container(
width: 200.0,
height: 200.0,
color: Colors.yellow,
child: const Text(
'this is a test',
style: TextStyle(fontSize: 14.0, color: Colors.yellowAccent),
),
),
),
)
);
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
});
group('custom minimum contrast guideline', () {