Unverified Commit 35a7f437 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Fix FAB Tooltip semantics label (#16072)

parent 69f0c839
......@@ -253,6 +253,17 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
);
}
if (widget.tooltip != null) {
// The long-pressable area for the tooltip should always be as big as
// the tooltip even if there is no child.
result = new SizedBox.expand(
child: new Tooltip(
message: widget.tooltip,
child: result,
),
);
}
result = new RawMaterialButton(
onPressed: widget.onPressed,
onHighlightChanged: _handleHighlightChanged,
......@@ -267,13 +278,6 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
child: result,
);
if (widget.tooltip != null) {
result = new Tooltip(
message: widget.tooltip,
child: result,
);
}
if (widget.heroTag != null) {
result = new Hero(
tag: widget.heroTag,
......
......@@ -253,6 +253,40 @@ void main() {
semantics.dispose();
});
testWidgets('Tooltip is used as semantics label', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(
new MaterialApp(
home: new Scaffold(
floatingActionButton: new FloatingActionButton(
onPressed: () { },
tooltip: 'Add Photo',
child: const Icon(Icons.add_a_photo),
),
),
),
);
expect(semantics, hasSemantics(new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
label: 'Add Photo',
actions: <SemanticsAction>[
SemanticsAction.tap
],
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semantics.dispose();
});
group('ComputeNotch', () {
testWidgets('host and guest must intersect', (WidgetTester tester) async {
final ComputeNotch computeNotch = await fetchComputeNotch(tester, const FloatingActionButton(onPressed: null));
......
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