Skip to content

feat: add showToolbarOnTap option for iOS single-tap context menu#236

Open
futaba3 wants to merge 1 commit into
Tkko:masterfrom
futaba3:fix/ios-single-tap-context-menu
Open

feat: add showToolbarOnTap option for iOS single-tap context menu#236
futaba3 wants to merge 1 commit into
Tkko:masterfrom
futaba3:fix/ios-single-tap-context-menu

Conversation

@futaba3

@futaba3 futaba3 commented Jun 26, 2026

Copy link
Copy Markdown

Description

Adds showToolbarOnTap parameter to enable the standard iOS single-tap context menu behavior (Paste, Select All, etc.) when opted in.

Closes #235

Motivation

As described in #235, on iOS, tapping an already-focused Pinput does not show the context menu — only a long press triggers it. The standard Flutter TextField toggles the context menu on a single tap when the field is already focused, so this PR adds an opt-in parameter to bring that behavior to Pinput.

I opted for a new parameter rather than changing the default behavior, since the current behavior may be intentional (e.g. to avoid accidental toolbar appearance during the initial focus transition). If there is a reason the existing behavior is by design, I'd love to hear it — happy to adjust the approach accordingly.

Implementation notes

Simply removing hideToolbar() from onSingleTapUp was not sufficient due to two constraints I ran into:

  1. _handleSelectionChanged rewrites the selection on every tap, so the framework's toggleToolbar condition (previousSelection == currentSelection) always resolves to hideToolbar rather than toggling.
  2. rendererIgnoresPointer: true leaves _selectionOverlay as null, so showToolbar() does nothing in this case — toggleToolbar() is needed because it creates the overlay when null.

As a workaround, toolbar visibility is tracked with a manual _isToolbarVisible flag, since EditableTextState.toolbarIsVisible is not accessible from outside the framework.

Testing

  • Verified on iOS simulator (Flutter 3.41.4, iOS 26.2)
  • Verified on Android device (Flutter 3.41.4, Android13) — behavior unchanged
  • showToolbarOnTap: false (default): long-press-only behavior unchanged
  • showToolbarOnTap: true: 1st tap focuses, 2nd tap shows menu, 3rd tap hides menu
  • Added widget tests for iOS and Android variants
  • Note: actual context menu rendering is OS-level UI and cannot be verified in widget tests

Demo (showToolbarOnTap: true, iOS)

The demo was recorded with showToolbarOnTap: true set in the example app for
verification purposes. This parameter is not changed in the example app in this PR.

before after
iOS
CleanShot.2026-06-26.at.15.21.09.mp4
CleanShot.2026-06-26.at.14.54.32.mp4
Android
XRecorder_26062026_150152.mp4
Behavior unchanged

Breaking Changes

None — showToolbarOnTap defaults to false, preserving existing behavior.


This is my first contribution to an open source project. If anything looks off — code style, approach, or anything else — please let me know and I'll be happy to update it.

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.

Support showing context menu on single tap on iOS (like standard TextField)

1 participant