Unverified Commit 049ea73c authored by chunhtai's avatar chunhtai Committed by GitHub

MinimumTextContrastGuideline should exclude disabled component (#94489)

parent bccc9eac
......@@ -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>[];
......
......@@ -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', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment