feat: add showToolbarOnTap option for iOS single-tap context menu#236
Open
futaba3 wants to merge 1 commit into
Open
feat: add showToolbarOnTap option for iOS single-tap context menu#236futaba3 wants to merge 1 commit into
futaba3 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
showToolbarOnTapparameter 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
TextFieldtoggles 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()fromonSingleTapUpwas not sufficient due to two constraints I ran into:_handleSelectionChangedrewrites the selection on every tap, so the framework'stoggleToolbarcondition (previousSelection == currentSelection) always resolves tohideToolbarrather than toggling.rendererIgnoresPointer: trueleaves_selectionOverlayas null, soshowToolbar()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
_isToolbarVisibleflag, sinceEditableTextState.toolbarIsVisibleis not accessible from outside the framework.Testing
showToolbarOnTap: false(default): long-press-only behavior unchangedshowToolbarOnTap: true: 1st tap focuses, 2nd tap shows menu, 3rd tap hides menuDemo (showToolbarOnTap: true, iOS)
CleanShot.2026-06-26.at.15.21.09.mp4
CleanShot.2026-06-26.at.14.54.32.mp4
XRecorder_26062026_150152.mp4
Breaking Changes
None —
showToolbarOnTapdefaults tofalse, 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.