File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -4770,7 +4770,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
47704770 compositeCallback: _compositeCallback,
47714771 enabled: _hasInputConnection,
47724772 child: TextFieldTapRegion (
4773- onTapOutside: widget.onTapOutside ?? _defaultOnTapOutside,
4773+ onTapOutside: _hasFocus ? widget.onTapOutside ?? _defaultOnTapOutside : null ,
47744774 debugLabel: kReleaseMode ? null : 'EditableText' ,
47754775 child: MouseRegion (
47764776 cursor: widget.mouseCursor ?? SystemMouseCursors .text,
Original file line number Diff line number Diff line change @@ -773,6 +773,7 @@ void main() {
773773 children: < Widget > [
774774 const Text ('Outside' ),
775775 TextFormField (
776+ autofocus: true ,
776777 onTapOutside: (PointerEvent event) {
777778 tapOutsideCount += 1 ;
778779 },
@@ -793,6 +794,37 @@ void main() {
793794 expect (tapOutsideCount, 3 );
794795 });
795796
797+ // Regression test for https://github.com/flutter/flutter/issues/134341.
798+ testWidgetsWithLeakTracking ('onTapOutside is not called upon tap outside when field is not focused' , (WidgetTester tester) async {
799+ int tapOutsideCount = 0 ;
800+ await tester.pumpWidget (
801+ MaterialApp (
802+ home: Material (
803+ child: Center (
804+ child: Column (
805+ children: < Widget > [
806+ const Text ('Outside' ),
807+ TextFormField (
808+ onTapOutside: (PointerEvent event) {
809+ tapOutsideCount += 1 ;
810+ },
811+ ),
812+ ],
813+ ),
814+ ),
815+ ),
816+ ),
817+ );
818+ await tester.pump ();
819+
820+ expect (tapOutsideCount, 0 );
821+ await tester.tap (find.byType (TextFormField ));
822+ await tester.tap (find.text ('Outside' ));
823+ await tester.tap (find.text ('Outside' ));
824+ await tester.tap (find.text ('Outside' ));
825+ expect (tapOutsideCount, 0 );
826+ });
827+
796828 // Regression test for https://github.com/flutter/flutter/issues/54472.
797829 testWidgetsWithLeakTracking ('reset resets the text fields value to the initialValue' , (WidgetTester tester) async {
798830 await tester.pumpWidget (
You can’t perform that action at this time.
0 commit comments