Skip to content

TextField doesn't report "up" event in onTapOutside #138190

@matthew-carroll

Description

@matthew-carroll

Is there an existing issue for this?

Steps to reproduce

  1. Use the provided repro code
  2. Tap on the text field to give it focus
  3. Tap outside the text field to trigger the onTapOutside callback

Expected results

The onTapOutside is called twice - once for a down event, and once for an up event.

Actual results

The onTapOutside is only called once, for a "down" event.

Code sample

Code sample
import 'package:flutter/material.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        scaffoldBackgroundColor: darkBlue,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 350,
        child: TextField(
          onTapOutside: (event) {
            print("Tap outside event - is down? ${event.down}");
          }
        ),
      ),
    );
  }
}

Screenshots or Video

NA

Logs

Logs
Tap outside event - is down? true

Flutter Doctor output

This reproduction works on DartPad.dev, but I've also reproduced locally in an iOS simulator:

Version output
Flutter 3.16.0-12.0.pre.41 • channel master • https://github.com/flutter/flutter.git
Framework • revision 4b72a6e831 (4 weeks ago) • 2023-10-14 01:01:03 -0400
Engine • revision 472be42e90
Tools • Dart 3.3.0 (build 3.3.0-26.0.dev) • DevTools 2.28.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: gesturesflutter/packages/flutter/gestures repository.f: material designflutter/packages/flutter/material repository.found in release: 3.13Found to occur in 3.13found in release: 3.17Found to occur in 3.17has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions