Skip to content

fix: let quick taps switch tabs on the iOS 26 native tab bar - #175

Open
aykuttasil wants to merge 1 commit into
berkaycatak:mainfrom
aykuttasil:fix/ios26-tab-bar-quick-tap
Open

aykuttasil wants to merge 1 commit into
berkaycatak:mainfrom
aykuttasil:fix/ios26-tab-bar-quick-tap

Conversation

@aykuttasil

Copy link
Copy Markdown

Description

On iOS 26+, tapping a tab of the native UITabBar (AdaptiveBottomNavigationBar with useNativeBottomBar: true) often does nothing: the selection does not move and onTap is not called. Pressing and dragging across the bar does switch tabs. A slow, held tap (~300 ms) also works. A quick tap does not.

This is not the wrapping GestureDetector described in #35 and #54. The example app has none, and Flutter's gesture arena diagnostics show the tab bar's recognizer as the only member, winning by default on pointer down.

The cause is in how the engine delivers touches to a platform view under the default Eager gesture blocking policy. FlutterTouchInterceptingView adds a FlutterDelayingGestureRecognizer (delaysTouchesBegan / delaysTouchesEnded = YES) that holds the touches back from the native view. It lets them through only when the framework's accept reaches iOS, and that accept is an asynchronous platform-channel message. A quick tap's touches have already ended by then. They reach the UITabBar late, together, and the iOS 26 tab bar does not treat that as a selection. A drag or a held tap lasts long enough for the accept to arrive while the finger is still down.

Flutter 3.47 added FlutterPlatformViewGestureRecognizersBlockingPolicyDoNotBlockGesture for platform views that run into this (flutter/flutter#175099). It skips the delaying recognizer and decides blocking from the hit test, so the tab bar gets its touches immediately. This PR registers the tab bar platform view with that policy.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement

Related Issues

Same symptom as #35 and #54 ("only drag works"), with a different cause; see the Description.

Changes Made

  • AdaptivePlatformUiPlugin.swift: register adaptive_platform_ui/ios26_tab_bar with the "do not block" gesture policy.
  • The policy is spelled by its raw value (FlutterPlatformViewGestureRecognizersBlockingPolicy(rawValue: 2)), in one named constant with a comment. The named constant only exists in Flutter 3.47+ headers, and pubspec.yaml allows flutter: ">=1.17.0", so naming it would break the iOS build for everyone on an older Flutter. With the raw value the plugin still compiles there. An older engine does not know the value: it still adds the delaying recognizer and never blocks, so quick taps behave as they do today.
  • CHANGELOG.md: a FIX entry under [Unreleased].
  • Only the tab bar changes. The other platform views keep the default policy.

Testing

Automated Tests ⚠️ REQUIRED

  • I have added unit/widget tests for my changes
  • All new and existing tests pass locally (flutter test): 331 passed
  • Code analysis passes with no errors (flutter analyze --fatal-infos)
  • Code formatting is correct (dart format): no Dart files changed
  • Test coverage is adequate (>80% for new code)

No test is added. The change is one argument to a native registration call, and the fix is in when UIKit delivers touches to the native view. flutter test runs no UIKit and no engine platform-view code, so a widget test cannot fail without the fix. The behavior was checked on a simulator instead (below). If you would like a test for this, I'm happy to add one in the form you prefer.

The raw-value spelling was type-checked separately: a Swift file using FlutterPlatformViewGestureRecognizersBlockingPolicy(rawValue: 2) compiles against a module that declares the enum the way Flutter 3.35.6 does (Eager and WaitUntilTouchesEnded only). I did not build the example with Flutter 3.35.6 itself.

Manual Testing

  • iOS 26+ tested: iPhone 17 simulator, iOS 27.0, Flutter 3.47.5, example app main page
  • iOS <26 tested: not affected; the native tab bar platform view is only created on iOS 26+
  • Android tested: not affected; iOS-only Swift change
  • Web tested (if applicable)
  • Tested in both light and dark mode: light only
  • Tested with different screen sizes
  • Tested with accessibility features (large fonts, screen readers, etc.)

Screenshots/Videos

Before

Example app on main: quick taps on Info, Profile and Search switched tabs 0 times out of 3. The selection stayed on Home.

After

Example app on this branch: quick taps Home → Info → Profile → Home each switched tabs on the first tap (3/3).

The same fix, applied to a vendored copy in a production app, took quick taps from "do nothing" to 4/4 tab switches.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation: no public API change
  • My changes generate no new warnings
  • I have checked that my code does not introduce any accessibility issues
  • I have updated the CHANGELOG.md file (if applicable)
  • I have updated version number in pubspec.yaml (if applicable): left to the release
  • I have added examples to the example app (if adding new widgets): no new widget

Breaking Changes

None. On Flutter <3.47 behavior is unchanged.

Additional Notes

  • With "do not block", Flutter no longer holds back the tab bar's own gestures when a Flutter widget wins the gesture arena. The tab bar sits on top of the page, so nothing in the package competes for those touches.
  • If you prefer to keep the old behavior by default, the policy can also be chosen per view from Dart with UiKitView(gestureBlockingPolicy: UiKitViewGestureBlockingPolicy.doNotBlockGesture), but that parameter also needs Flutter 3.47+, so it would raise the minimum Flutter version.

🤖 Generated with Claude Code

The engine's default eager gesture blocking policy holds the UITabBar's
touches until the Dart gesture arena accepts them, which arrives over an
asynchronous platform channel. A quick tap ends before that and the tab
bar drops it; only press-and-drag switched tabs.

Register the tab bar platform view with the 'do not block' policy
(Flutter 3.47+, flutter/flutter#175099), spelled by raw value so the
plugin still compiles against older Flutter headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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