Skip to content

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

Description

@futaba3

First of all, thank you for maintaining Pinput — it has been incredibly helpful for our projects!

Is your feature request related to a problem? Please describe.

On iOS, tapping an already-focused Pinput field does not show the context menu (Paste, Select All, etc.). Only a long press triggers it. However, the standard Flutter TextField shows the context menu on a single tap when the field is already focused.

This behavior differs slightly from the standard iOS text field UX, where a single tap on a focused field toggles the context menu.

Describe the solution you'd like

If this is unintentional, restoring the standard iOS behavior for all users would be ideal. If it is intentional and backward compatibility is a concern, an opt-in option like showToolbarOnTap: bool could be an alternative.

Describe alternatives you've considered

Looking at _PinputSelectionGestureDetectorBuilder.onSingleTapUp(), it currently calls hideToolbar() right after super.onSingleTapUp():

@override
void onSingleTapUp(details) {
  super.onSingleTapUp(details);
  editableText.hideToolbar(); // This cancels the toggleToolbar that the framework just triggered
  _state._requestKeyboard();
  _state.widget.onTap?.call();
}

On iOS, super.onSingleTapUp() calls toggleToolbar() internally when the field is already focused. Calling editableText.hideToolbar() here unconditionally suppresses that framework-level toggle behavior.

I tested this both with and without contextMenuBuilder. The issue reproduces in both cases. Simply removing hideToolbar() was not sufficient — I ended up tracking toolbar visibility with a manual flag to get it working.

I noticed that some other PIN packages behave similarly (long press only). If there is a technical reason why the single-tap context menu is intentionally suppressed here (e.g., preventing the toolbar from showing up during the initial focus), I'd love to understand the background.

I have a workaround running in a local fork, though it hasn't been thoroughly tested.

Additional context

  • pinput: 6.0.2
  • Flutter: 3.41.4 (stable)
  • Platform: iOS

Related: flutter/flutter#48434

Thanks for your time and consideration!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions