-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to Reproduce
There seems to be an inconsistency how selection is handled within a scrollable. When performing a scroll on a SelectionArea, the selection is cleared. When performing a scroll on any other element, the selection remains.
Case 1:
- Execute
flutter runon the code sample - Select text in the "Selectable" text block
- Scroll on the "Selectable" text block
Result: The selection is cleared as soon as a scroll on text is performed
Case 2:
- Execute
flutter runon the code sample - Select text in the "Selectable" text block
- Scroll on the "Not Selectable" text block
Result: The selection remains, and the selection handles can display outside the scroll viewport when scrolled.
Screen.Recording.2023-02-16.at.16.31.31.mov
Expected result
I am not 100% sure what the expected result here would be. For native applications, the selection remains when scrolled, and the selection handles are either removed or clipped when the selection is outside the scroll viewport.
For Flutter, it seems to bring some unintended issues which can be seen when doing Case 2. The selection handles can display outside the scroll viewport, which seems like a case not handled in the current implementation of selection.
To summarise: I would at least expect that selection handles do not display outside the scroll viewport, since this looks like a visual bug to the end user.
Code Sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(),
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text("Selection Inconsistency"),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
children: [
Text(
"Selectable",
style: Theme.of(context).textTheme.headline5,
),
SelectionArea(child: Text("Lorem Ipsum " * 75)),
const SizedBox(height: 100),
Text(
"Not Selectable",
style: Theme.of(context).textTheme.headline5,
),
Text("Lorem Ipsum " * 75),
],
),
),
),
);
}
}Flutter Doctor
[!] Flutter (Channel master, 3.8.0-13.0.pre.54, on macOS 12.2 21D49 darwin-arm64, locale en-DE)
! Upstream repository https://github.com/jankuss/flutter is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to https://github.com/jankuss/flutter to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] IntelliJ IDEA Community Edition (version 2021.3.3)
[✓] VS Code (version 1.74.3)
[✓] Connected device (3 available)
[✓] Network resources
