Fix FAB Tooltip semantics label (#16072)
This commit is contained in:
committed by
GitHub
parent
69f0c839d2
commit
35a7f43749
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user