Repository navigation
Commit 5909913
authored
[material_ui] Add tertiary tap callbacks to InkResponse and InkWell (flutter#12676)
Ported from flutter#191971, which was opened against `flutter/flutter` before I noticed the Material code freeze (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#129058
## Pre-Review Checklist1 parent af6f7ac commit 5909913
3 files changed
Lines changed: 186 additions & 1 deletion
File tree
- packages/material_ui
- lib/src
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
318 | 321 | | |
319 | 322 | | |
320 | 323 | | |
| |||
410 | 413 | | |
411 | 414 | | |
412 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
413 | 445 | | |
414 | 446 | | |
415 | 447 | | |
| |||
674 | 706 | | |
675 | 707 | | |
676 | 708 | | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
677 | 712 | | |
678 | 713 | | |
679 | 714 | | |
| |||
732 | 767 | | |
733 | 768 | | |
734 | 769 | | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
735 | 773 | | |
736 | 774 | | |
737 | 775 | | |
| |||
771 | 809 | | |
772 | 810 | | |
773 | 811 | | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
774 | 815 | | |
775 | 816 | | |
776 | 817 | | |
| |||
815 | 856 | | |
816 | 857 | | |
817 | 858 | | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
818 | 862 | | |
819 | 863 | | |
820 | 864 | | |
| |||
1183 | 1227 | | |
1184 | 1228 | | |
1185 | 1229 | | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1186 | 1249 | | |
1187 | 1250 | | |
1188 | 1251 | | |
| |||
1284 | 1347 | | |
1285 | 1348 | | |
1286 | 1349 | | |
1287 | | - | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
1288 | 1353 | | |
1289 | 1354 | | |
1290 | 1355 | | |
| |||
1302 | 1367 | | |
1303 | 1368 | | |
1304 | 1369 | | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
1305 | 1374 | | |
1306 | 1375 | | |
1307 | 1376 | | |
| 1377 | + | |
1308 | 1378 | | |
1309 | 1379 | | |
1310 | 1380 | | |
| |||
1409 | 1479 | | |
1410 | 1480 | | |
1411 | 1481 | | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
1412 | 1485 | | |
1413 | 1486 | | |
1414 | 1487 | | |
| |||
1524 | 1597 | | |
1525 | 1598 | | |
1526 | 1599 | | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
1527 | 1603 | | |
1528 | 1604 | | |
1529 | 1605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2500 | 2500 | | |
2501 | 2501 | | |
2502 | 2502 | | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
2503 | 2609 | | |
2504 | 2610 | | |
2505 | 2611 | | |
| |||
0 commit comments