Skip to content

CompositedTransformFollower responds to taps even when showWhenUnlinked is false #21320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AbdulRahmanAlHamali opened this issue Sep 1, 2018 · 6 comments · Fixed by #54981
Closed
Assignees
Labels
customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: money (g3) f: gestures flutter/packages/flutter/gestures repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Comments

@AbdulRahmanAlHamali
Copy link

AbdulRahmanAlHamali commented Sep 1, 2018

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!

@shakil807g
Copy link

how about manually hiding CompositedTransformFollower when showWhenUnlinked is false ??

@AbdulRahmanAlHamali
Copy link
Author

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

@zoechi zoechi added framework flutter/packages/flutter repository. See also f: labels. f: gestures flutter/packages/flutter/gestures repository. labels Sep 4, 2018
@goderbauer goderbauer added the f: scrolling Viewports, list views, slivers, etc. label Jan 3, 2019
@BondarenkoStas
Copy link

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

@jkmpariab
Copy link

jkmpariab commented Nov 1, 2019

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
Copy link

sh0umik commented Jan 20, 2020

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

@lock
Copy link

lock bot commented May 5, 2020

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.

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: money (g3) f: gestures flutter/packages/flutter/gestures repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants