Skip to content

[CP-Stable] Fix BaseTapAndDragGestureRecognizer drag state after losing gesture arena #153939

Closed

Description

@Renzo-Olivares

Issue Link

#153458

Target

stable

Cherry pick PR Link

#153935

Changelog Description

Fixes an issue where Flutter TextField may crash on iOS.

Impacted Users

Users of Flutter TextField on iOS, and users of BaseTapAndDragGestureRecognizer with eagerVictoryOnDrag set to false

Impact Description

On debug builds this triggers an assertion when using a TextField on iOS does a horizontal swipe or pan that doesn't meet the drag threshold to win the gesture arena and leaves TextField gestures in a weird state where no other tap gestures are accepted.

Workaround

No workaround, issue is with internal implementation of BaseTapAndDragGestureRecognizer.

Risk

low

Test Coverage

yes

Validation Steps

Run the example below on iOS, tap the TextField to focus it, and then do a horizontal drag somewhere not on the cursor. Then try to tap somewhere else. The cursor should be moved to the word edge closest to the tapped position.

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final TextEditingController _controller = TextEditingController(text: 'Some long text that should scroll. ' * 20);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: TextField(
            controller: _controller,
            maxLines: 5,
          ),
        ),
      ),
    );
  }
}

Activity

  1. changed the title [-][CP] Fix BaseTapAndDragGestureRecognizer drag state after losing gesture arena[/-] [+][CP-Stable] Fix BaseTapAndDragGestureRecognizer drag state after losing gesture arena[/+] on Aug 26, 2024
  2. added 2 commits that reference this issue on Aug 27, 2024
    bc472b4
    aa23c25
  3. github-actions commented on Sep 24, 2024

    @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.

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

Metadata

Metadata

Assignees

Labels

cp: reviewCherry-picks in the review queue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions