Skip to content

When selection text on SelectableText.rich with long press, it changes scroll position. #84480

@demirdev

Description

@demirdev

Steps to Reproduce

  1. Run Flutter Code at below.
  2. In simulator, Scroll down to line starts with 109 or something else (wait for scroll stopping itself).
  3. Long press a word.
  4. if scroll position not changes, repeat (steps: 2-3) several times

Expected results: Scroll Position must do not change.

Actual results: Scroll Position changes.

Simulator.Screen.Recording.-.iPhone.8.-.2021-06-12.at.05.09.41.mp4
Flutter Code
import 'package:flutter/material.dart';

class TestScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [IconButton(onPressed: () {}, icon: Icon(Icons.info))],
      ),
      body: SafeArea(
        child: SelectableText.rich(
          TextSpan(
              text: List.generate(
                      1000,
                      (index) =>
                          "${index} This is test. This is test. This is test. This is test. \n")
                  .join(' ')),
          onSelectionChanged: (selection, cause) {
            print('changed selection');
            print(selection);
            print(cause);
          },
          scrollPhysics: AlwaysScrollableScrollPhysics(),
        ),
      ),
    );
  }
}
Logs

flutter doctor -v
[✓] Flutter (Channel stable, 2.2.0, on macOS 11.4 20F71 darwin-x64, locale en-TR)
    • Flutter version 2.2.0 at /Users/mehmet/Developer/flutter
    • Framework revision b22742018b (4 weeks ago), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/mehmet/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.57.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0

[✓] Connected device (2 available)
    • iPhone 8 (mobile) • DC0D1CCB-DBC8-4BB7-B12D-17C4EE6519C4 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)      • chrome                               • web-javascript • Google Chrome 91.0.4472.77

• No issues found!


Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxtc: regressionIt was better in the past than it is nowf: gesturesflutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.found in release: 2.2Found to occur in 2.2frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsworkaround availableThere is a workaround available to overcome the issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions