Skip to content

Add tertiary tap callbacks to InkResponse and InkWell - #191971

Closed
Ahtsham0715 wants to merge 1 commit into
flutter:masterfrom
Ahtsham0715:inkwell-tertiary-tap-callbacks
Closed

Ahtsham0715 wants to merge 1 commit into
flutter:masterfrom
Ahtsham0715:inkwell-tertiary-tap-callbacks

Conversation

@Ahtsham0715

@Ahtsham0715 Ahtsham0715 commented Aug 28, 2026 •

Copy link
Copy Markdown

GestureDetector exposes onTertiaryTapDown, onTertiaryTapUp and onTertiaryTapCancel, but InkResponse/InkWell only forwarded the primary and secondary button callbacks. That means a middle click on an InkWell — the usual way to open a link in a new tab or window on desktop and web — can't be handled without wrapping the widget in a second gesture detector, which then has to be reconciled with the ink splash.

This PR adds the three tertiary callbacks to InkResponse and InkWell, mirroring the existing secondary button plumbing:

  • The pressed highlight and ink splash start on tertiary tap down and are resolved on tap up or cancel, exactly as they are for the secondary button.
  • The tertiary button is only listened for when onTertiaryTapDown or onTertiaryTapUp is non-null, so widgets that don't opt in behave exactly as before (no splash on middle click, same as today).
  • onTertiaryTapCancel alone does not enable the button, which matches how onSecondaryTapCancel already behaves.

There is no onTertiaryTap because TapGestureRecognizer/GestureDetector don't have one; onTertiaryTapUp is the completion signal for that button.

This follows the approach suggested in the issue: a specific widget with a concrete use case, rather than a general reworking of the button callback pattern.

Tests added to packages/flutter/test/material/ink_well_test.dart:

  • InkWell tertiary tap test — verifies the down/up ordering on a completed middle click, and down/cancel when the pointer is dragged away.
  • InkWell tertiary tap highlights only when a tertiary callback is defined — verifies the pressed highlight is raised and lowered on a tertiary press when a tertiary callback is supplied, and that a tertiary press is ignored when one is not.

Fixes #129058

Pre-launch Checklist

`GestureDetector` exposes `onTertiaryTapDown`, `onTertiaryTapUp` and
`onTertiaryTapCancel`, but `InkResponse`/`InkWell` only forwarded the
primary and secondary button callbacks. This meant a middle click on an
`InkWell` (a common way to open a link in a new tab or window) could not
be handled without wrapping the widget in another gesture detector.

This adds the three tertiary callbacks, mirroring the existing secondary
button plumbing: the ink splash and pressed highlight are started on
tertiary tap down and resolved on tap up or cancel, and the widget only
listens for the tertiary button when at least one of
`onTertiaryTapDown`/`onTertiaryTapUp` is provided, so existing widgets
are unaffected.

Fixes flutter#129058
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Aug 28, 2026
@github-actions

Copy link
Copy Markdown

This pull request contains changes to Material or Cupertino, which are currently frozen in this repository.

Changes should be made in material_ui and/or cupertino_ui in the flutter/packages repository.

Please refer to #188444 for instructions.

@Ahtsham0715

Copy link
Copy Markdown
Author

Material is frozen in this repository, so this has been ported to material_ui in flutter/packages: flutter/packages#12676. Closing here.

@Ahtsham0715
Ahtsham0715 deleted the inkwell-tertiary-tap-callbacks branch August 28, 2026 17:18
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 14, 2026
…12676)

Ported from flutter/flutter#191971, which was opened against `flutter/flutter` before I noticed the Material code freeze (flutter/flutter#188444). That PR has been closed in favour of this one.

`GestureDetector` exposes `onTertiaryTapDown`, `onTertiaryTapUp` and `onTertiaryTapCancel`, but `InkResponse`/`InkWell` only forward the primary and secondary button callbacks. That means a middle click on an `InkWell` — the usual way to open a link in a new tab or window on desktop and web — can't be handled without wrapping the widget in a second gesture detector, which then has to be reconciled with the ink splash.

This PR adds the three tertiary callbacks to `InkResponse` and `InkWell`, mirroring the existing secondary button plumbing:

- The pressed highlight and ink splash start on tertiary tap down and are resolved on tap up or cancel, exactly as they are for the secondary button.
- The tertiary button is only listened for when `onTertiaryTapDown` or `onTertiaryTapUp` is non-null, so widgets that don't opt in behave exactly as before (no splash on middle click, same as today).
- `onTertiaryTapCancel` alone does not enable the button, which matches how `onSecondaryTapCancel` already behaves.

There is no `onTertiaryTap` because `TapGestureRecognizer`/`GestureDetector` don't have one; `onTertiaryTapUp` is the completion signal for that button.

This follows the approach suggested in the issue: a specific widget with a concrete use case, rather than a general reworking of the button callback pattern.

**Tests added** to `packages/material_ui/test/ink_well_test.dart`:

- `InkWell tertiary tap test` — verifies the down/up ordering on a completed middle click, and down/cancel when the pointer is dragged away.
- `InkWell tertiary tap highlights only when a tertiary callback is defined` — verifies the pressed highlight is raised and lowered on a tertiary press when a tertiary callback is supplied, and that a tertiary press is ignored when one is not.

A pending changelog entry is included with a `minor` version bump, since this is additive API.

Fixes flutter/flutter#129058

## Pre-Review Checklist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InkWell does not expose callbacks for handling tertiary taps

1 participant