Repository navigation
Add tertiary tap callbacks to InkResponse and InkWell - #191971
Closed
Ahtsham0715 wants to merge 1 commit into
Closed
Ahtsham0715 wants to merge 1 commit into
Ahtsham0715 wants to merge 1 commit into
Conversation
`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
8 of 10 tasks
|
This pull request contains changes to Material or Cupertino, which are currently frozen in this repository. Changes should be made in Please refer to #188444 for instructions. |
11 tasks done
Author
|
Material is frozen in this repository, so this has been ported to material_ui in flutter/packages: flutter/packages#12676. Closing here. |
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
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.
GestureDetectorexposesonTertiaryTapDown,onTertiaryTapUpandonTertiaryTapCancel, butInkResponse/InkWellonly forwarded the primary and secondary button callbacks. That means a middle click on anInkWell— 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
InkResponseandInkWell, mirroring the existing secondary button plumbing:onTertiaryTapDownoronTertiaryTapUpis non-null, so widgets that don't opt in behave exactly as before (no splash on middle click, same as today).onTertiaryTapCancelalone does not enable the button, which matches howonSecondaryTapCancelalready behaves.There is no
onTertiaryTapbecauseTapGestureRecognizer/GestureDetectordon't have one;onTertiaryTapUpis 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
///).