Skip to content

Dragging the collapsed cursor doesn't match native #118268

Closed

Description

@justinmc

When dragging the collapsed cursor in a text field on Android and iOS, 1. the loupe does not appear and 2. edge scrolling doesn't work. This is referring to dragging the cursor itself, not dragging the collapsed selection handle (which does work on Android and doesn't exist on iOS).

Scenario Dragging the collapsed handle Dragging the cursor
Flutter on Android ✅ android_handle ❌ android_cursor
Flutter on iOS n/a ❌ ios_drag

Steps to reproduce

  1. Run any app with multiple lines of editable text, such as the one given below.
  2. Tap to place the cursor.
  3. Perform a drag gesture on the cursor.

Expected: The cursor follows the drag, the loupe appears, and edge scrolling works.
Actual: The cursor does follow the drag, but the loupe doesn't appear, and scrolling off the edge causes the cursor to stop following the drag instead of scrolling.

Repro code
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(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final TextEditingController _controller = TextEditingController(
    text: 'Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,\nsed diam voluptua.\nAt vero eos et accusam et justo duo dolores et ea rebum.\nStet clita kasd gubergren,\nno sea takimata sanctus est Lorem ipsum dolor sit amet.',
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField(
              controller: _controller,
              minLines: 4,
              maxLines: 4,
            ),
          ],
        ),
      ),
    );
  }
}

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    on Jan 10, 2023
  2. changed the title [-]Dragging the cursor doesn't match native[/-] [+]Dragging the collapsed cursor doesn't match native[/+] on Jan 10, 2023
  3. justinmc commented on Jan 10, 2023

    @justinmc
    ContributorAuthor

    CC @Renzo-Olivares, you mentioned that this was probably caused by your tap and drag work.

  4. Renzo-Olivares commented on Jan 11, 2023

    @Renzo-Olivares
    Contributor

    This looks its the expected behavior on native iOS. I tried in the iMessage input field and the cursor will not follow the drag unless the drag begins on the cursor itself. If it doesn't the TextField just scrolls up and down.

  5. Renzo-Olivares commented on Jan 11, 2023

    @Renzo-Olivares
    Contributor

    On native Android I'm noticing that scrolling up and down, the cursor doesn't exactly move with the drag but it is placed somewhere in the current visible text view.

  6. added a commit that references this issue on Apr 20, 2023
    8ed26d8
  7. github-actions commented on May 4, 2023

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions