Skip to content

Keep focus when tapping within IgnoreKeyboardDismiss - #192

Merged
MisterJimson merged 2 commits into
MisterJimson:masterfrom
aniJani:fix/ignore-keyboard-dismiss-mouse-taps
Aug 24, 2026
Merged

Keep focus when tapping within IgnoreKeyboardDismiss#192
MisterJimson merged 2 commits into
MisterJimson:masterfrom
aniJani:fix/ignore-keyboard-dismiss-mouse-taps

Conversation

@aniJani

@aniJani aniJani commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Resolves #184.

IgnoreKeyboardDismiss had no effect against the TextField's own dismissal. The reported case was mouse input, but the underlying problem is broader — see the table below.

Cause

Not the ignoreNextTap handshake, which fires in the correct order for every pointer kind. EditableText wraps its field in a TapRegion and unfocuses on a tap outside it. That runs on pointer down, before IgnoreKeyboardDismiss sets the flag, and independently of it.

The default tap-outside action unfocuses unconditionally on desktop targets, and for every kind except touch on mobile. Measured against IgnoreKeyboardDismiss before this change:

Target platform touch mouse
android / iOS / fuchsia ok dismissed
linux / macOS / windows dismissed dismissed

Fix

Wrap in TextFieldTapRegion, joining the EditableText tap-region group so taps inside the subtree are no longer "outside" the field. The existing flag still covers dismissals originating from KeyboardDismissOnTap itself, so dismissOnCapturedTaps behaviour is unchanged.

Tests

Two tests in the KeyboardDismissOnTap group, run under TargetPlatformVariant.all(). Nine of the twelve resulting cases fail without the change; the three that pass (touch on mobile targets) guard the previously-working path.

Also verified manually that an interactive child still works as intended — an ElevatedButton wrapped in IgnoreKeyboardDismiss fires onPressed and keeps focus for both pointer kinds, and a tap on an unrelated widget still dismisses.

aniJani and others added 2 commits August 4, 2026 02:56
A focused TextField unfocuses itself on taps outside its own TapRegion. That
happens on pointer down, before IgnoreKeyboardDismiss sets ignoreNextTap, and
independently of it, so the widget had no effect against that path.

Only mobile targets receiving touch input were spared. The default tap-outside
action unfocuses for every pointer kind on desktop targets, and for everything
but touch on mobile, leaving nine of the twelve platform and pointer-kind
combinations broken.

Joining the text field's tap region opts the subtree out of that path.

Resolves MisterJimson#184.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.24%. Comparing base (42ddef5) to head (ba870b6).
⚠️ Report is 5 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #192       +/-   ##
===========================================
+ Coverage   76.53%   89.24%   +12.71%     
===========================================
  Files           6        6               
  Lines          98       93        -5     
===========================================
+ Hits           75       83        +8     
+ Misses         23       10       -13     
Files with missing lines Coverage Δ
...visibility/lib/src/ui/keyboard_dismiss_on_tap.dart 85.29% <100.00%> (+35.29%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MisterJimson MisterJimson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed after updating onto current master. The focused regression tests pass, all analysis jobs pass, and Android/iOS/macOS/JavaScript/Wasm builds pass. The six publish dry-run jobs are failing because Flutter 3.47.1 rewrites checked-in analysis_options files before package validation; that is repository CI maintenance unrelated to this two-file change.

@MisterJimson
MisterJimson merged commit 8de2fc6 into MisterJimson:master Aug 24, 2026
13 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IgnoreKeyboardDismiss has no effect with mouse/pointer input (works with touch)

3 participants