Skip to content

Tooltip in a Table detaches its child on mouse move #51152

@dkwingsmt

Description

@dkwingsmt

When Tooltip is in a table, its child is detached when mouse moves, effectively making child disappear.

This does not happen when Tooltip is not in a table, or when the child is not in a Tooltip. The issue is possibly caused by the build method of Tooltip where _mouseIsConnected is switched from false to true.

Also, this issue disappears if the Tooltip is wrapped in an Inkwell.

See below for a unit test with a minimal example. You can also run the MaterialApp on a platform that supports mouse and see the effect.

Minimal example test case
  testWidgets(
    'Handles tooltip well',
    (WidgetTester tester) async {
      await tester.pumpWidget(
        MaterialApp(
          home: Center(
            child: Directionality(
              textDirection: TextDirection.ltr,
              child: Table(
              children: const <TableRow>[
                TableRow(children: <Widget>[
                  Tooltip(
                    message: 'HINT',
                    child: Text('CONTENT'),
                  ),
                ])
              ],
              ),
            ),
          ),
        ),
      );

      expect(find.text('CONTENT'), findsOneWidget);

      final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
      await gesture.addPointer(location: const Offset(20, 20));
      addTearDown(gesture.removePointer);

      await tester.pumpAndSettle();

      await gesture.moveTo(const Offset(10, 10));
      expect(tester.renderObject(find.text('CONTENT')).attached, isTrue); // Breaks currently
    },
  );
[✓] Flutter (Channel master, v1.15.4-pre.124, on Linux, locale en_US.UTF-8)
    • Flutter version 1.15.4-pre.124 at /usr/local/google/home/tongmu/dev/flutter
    • Framework revision 0b5667ac12 (2 hours ago), 2020-02-20 17:27:02 -0500
    • Engine revision 84dc383b64
    • Dart version 2.8.0 (build 2.8.0-dev.9.0 707ecda05e)

Related issue:

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: mouseIssues related to using a mouse or mouse supportf: material designflutter/packages/flutter/material repository.found in release: 1.20Found to occur in 1.20frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions