Skip to content

CompositedTransformFollower responds to taps even when showWhenUnlinked is false #21320

Closed
@AbdulRahmanAlHamali

Description

@AbdulRahmanAlHamali

Internal: b/153942448

Steps to Reproduce

If we have a CompositedTransformFollower that follows a CompositedTransformTarget, and we scroll the target out of the screen, the layer link between them gets broken. This results in the follower showing at the top left of the screen.

We can hide the follower by setting showWhenUnlinked to false, but it still responds to taps of the user.

To reproduce this, I created this small app:

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage();

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  LayerLink _layerLink = LayerLink();
  FocusNode _focusNode = FocusNode();

  @override
  void initState() {
    super.initState();

    _focusNode.addListener(() {
      if (_focusNode.hasFocus) {
        Overlay.of(context).insert(OverlayEntry(
          builder: (context) =>
            Positioned(
              width: 200.0,
              child: CompositedTransformFollower(
                link: this._layerLink,
                child: Material(
                  elevation: 4.0,
                  child: RaisedButton(
                      onPressed: () {
                        print('I was pressed');
                      }
                  ),
                ),
              ),
            )
        ));
      }
    });
  }

  @override
  Widget build(BuildContext context) {
     return new Scaffold(
       body: ListView(
         padding: EdgeInsets.all(20.0),
         children: <Widget>[
           SizedBox(height: 200.0,),
           CompositedTransformTarget(
             link: this._layerLink,
             child: TextField(
               focusNode: this._focusNode,
             ),
           ),
           SizedBox(height: 700.0,)
         ],
       )
    );
  }
}

If you focus the TextField, the button shows, then if you scroll the TextField out of the screen, you can see the button stays at the top left of the screen. If you tap the button, it prints to the console "I was pressed".

Now, set the showWhenUnlinked to false and repeat the procedure. Even though the button won't be showing anymore, it will still respond to taps.

Logs

[✓] Flutter (Channel beta, v0.6.0, on Linux, locale en_US.UTF-8)
    • Flutter version 0.6.0 at /home/aalhamali/flutter
    • Framework revision 9299c02cf7 (2 weeks ago), 2018-08-16 00:35:12 +0200
    • Engine revision e3687f70c7
    • Dart version 2.1.0-dev.0.0.flutter-be6309690f

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
    • Android SDK at /home/aalhamali/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.1
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.1)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 26.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Connected devices (1 available)
    • Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)

• No issues found!

Activity

shakil807g

shakil807g commented on Sep 2, 2018

@shakil807g

how about manually hiding CompositedTransformFollower when showWhenUnlinked is false ??

AbdulRahmanAlHamali

AbdulRahmanAlHamali commented on Sep 2, 2018

@AbdulRahmanAlHamali
Author

You mean when the follower is unlinked from the target? Is there an efficient way to listen to that?

added
frameworkflutter/packages/flutter repository. See also f: labels.
f: gesturesflutter/packages/flutter/gestures repository.
on Sep 4, 2018
BondarenkoStas

BondarenkoStas commented on Oct 24, 2019

@BondarenkoStas

did you find a solution? does the issue still exist with current flutter stable?

jkmpariab

jkmpariab commented on Nov 1, 2019

@jkmpariab

does the issue still exist with current flutter stable?

yes, the issue is still there

my 'flutter doctor -v'

[✓] Flutter (Channel master, v1.10.15-pre.351, on Linux, locale en_US.UTF-8)
    • Flutter version 1.10.15-pre.351 at /home/abed/.local/flutter
    • Framework revision 8e0799a657 (31 hours ago), 2019-10-30 23:33:38 -0700Engine revision b16eab6aff
    • Dart version 2.6.0 (build 2.6.0-dev.8.2 d50c158d42)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/abed/Android/SdkAndroid NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang++ 6.0.0GNU Make 4.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] IntelliJ IDEA Community Edition (version 2019.2)
    • IntelliJ at /opt/idea-ICFlutter plugin version 40.2.4Dart plugin version 192.7402

[✓] VS Code (version 1.39.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.5.1

[✓] Connected device (4 available)
    • Android SDK built for x86 • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • LinuxLinux         • linux-x64      • LinuxChrome                    • chrome        • web-javascript • Google Chrome 78.0.3904.70Web Server                • web-server    • web-javascript • Flutter Tools

! Doctor found issues in 1 category.
sh0umik

sh0umik commented on Jan 20, 2020

@sh0umik

this issue still exits . Found this bug while exploring flutter_typeahead package

added
customer: crowdAffects or could affect many people, though not necessarily a specific customer.
on Feb 27, 2020
lock

lock commented on May 5, 2020

@lock

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

customer: crowdAffects or could affect many people, though not necessarily a specific customer.customer: money (g3)f: gesturesflutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @zoechi@goderbauer@mehmetf@shakil807g@sh0umik

    Issue actions

      CompositedTransformFollower responds to taps even when showWhenUnlinked is false · Issue #21320 · flutter/flutter