Skip to content

fix: fire Ruby on_tap_outside_bar on Cupertino SearchBar - #43

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-search-bar-tap-outside
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-search-bar-tap-outside

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Summary

Ruby's SearchBar declares on_tap_outside_bar. The Material renderer passes onTapOutside to its bar's text field, and fires "tap_outside_bar" when the user taps outside the bar while it has focus, as EditableText does. On iOS and macOS, CupertinoSearchBarControl (cupertino_input_controls.dart) renders a CupertinoSearchTextField, which has no onTapOutside parameter, so the event never fired.

Fix

The CupertinoSearchTextField is wrapped in a TextFieldTapRegion (widgets layer). While the field has focus and on_tap_outside_bar is set, its onTapOutside fires "tap_outside_bar". Taps on the field's own selection toolbar count as inside the region, as they do for EditableText. The native default tap-outside behavior is unchanged.

The diff is mostly re-indentation from the wrapper. This file is also touched by #10 (DropdownM2), and they merge cleanly.

Tests

New test/widgets/ruby_search_bar_tap_outside_test.dart, run on iOS and Android:

  • Focus the bar, then tap outside: tap_outside_bar fires exactly once. The iOS case failed before the fix, with 0 events.
  • Tap outside while unfocused: no event, the same on both designs.

verify_pr.sh: flutter test +699, all passed (695 baseline + 4 new). flutter analyze lib test found no issues. Flutter 3.41.2.

Wave-2 follow-up P3 (SearchBar)

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.

1 participant