Commit 1461b65
authored
This PR adds a new quick trigger feature to the `Menu`. Not sure what
the best
name for this is, but essentially this is the behavior:
Recently we made sure that the `Menu` opens on `mousedown` (not just
`click`).
This means that we can perform the following quick action:
1. `mousedown` on the `MenuButton` — this will open the `Menu`
2. Without releasing the mouse button yet, move your mouse over one of
the `MenuItem`s — this will highlight the currently active `MenuItem`.
3. Release the mouse button — this will invoke the currently active
`MenuItem` and close the `Menu`.
This now means that you can perform actions very quickly.
What this PR doesn't do yet is if you have a scrollable list, then it
won't scroll up or down when you reach the ends of the list. For this we
would need to introduce some new elements. The native Menu items on
macOS show a little placeholder arrow. If you put your cursor in that
area, it starts scrolling:
<img width="489" alt="image"
src="https://github.com/user-attachments/assets/e3a90d5a-daa7-4711-9e19-050578be3e02"
/>
## Test plan
1. Everything still works as expected
2. Quick release has been added:
- Listbox:
https://headlessui-react-git-feat-quick-trigger-tailwindlabs.vercel.app/listbox/listbox-with-pure-tailwind
- Menu:
https://headlessui-react-git-feat-quick-trigger-tailwindlabs.vercel.app/menu/menu
- Combobox:
https://headlessui-react-git-feat-quick-trigger-tailwindlabs.vercel.app/combobox/combobox-countries
1 parent 730ab68 commit 1461b65
File tree
8 files changed
+255
-33
lines changed- jest
- packages/@headlessui-react
- src
- components
- combobox
- listbox
- hooks
- utils
8 files changed
+255
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
Lines changed: 41 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
989 | 991 | | |
990 | 992 | | |
991 | 993 | | |
992 | | - | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
993 | 999 | | |
994 | 1000 | | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
995 | 1031 | | |
996 | 1032 | | |
997 | 1033 | | |
| |||
1044 | 1080 | | |
1045 | 1081 | | |
1046 | 1082 | | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
1050 | 1086 | | |
1051 | 1087 | | |
1052 | 1088 | | |
| |||
1074 | 1110 | | |
1075 | 1111 | | |
1076 | 1112 | | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | 1113 | | |
1083 | 1114 | | |
1084 | 1115 | | |
| |||
1102 | 1133 | | |
1103 | 1134 | | |
1104 | 1135 | | |
1105 | | - | |
| 1136 | + | |
1106 | 1137 | | |
1107 | 1138 | | |
1108 | 1139 | | |
| |||
Lines changed: 36 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
362 | 395 | | |
363 | 396 | | |
364 | 397 | | |
| |||
393 | 426 | | |
394 | 427 | | |
395 | 428 | | |
396 | | - | |
| 429 | + | |
397 | 430 | | |
398 | 431 | | |
399 | 432 | | |
| |||
415 | 448 | | |
416 | 449 | | |
417 | 450 | | |
418 | | - | |
419 | | - | |
420 | 451 | | |
421 | 452 | | |
422 | 453 | | |
| |||
431 | 462 | | |
432 | 463 | | |
433 | 464 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | 465 | | |
439 | 466 | | |
440 | 467 | | |
| |||
451 | 478 | | |
452 | 479 | | |
453 | 480 | | |
454 | | - | |
| 481 | + | |
455 | 482 | | |
456 | 483 | | |
457 | 484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
| 228 | + | |
228 | 229 | | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
232 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
233 | 261 | | |
234 | 262 | | |
235 | 263 | | |
| |||
274 | 302 | | |
275 | 303 | | |
276 | 304 | | |
277 | | - | |
| 305 | + | |
278 | 306 | | |
279 | 307 | | |
280 | 308 | | |
| |||
640 | 668 | | |
641 | 669 | | |
642 | 670 | | |
643 | | - | |
644 | | - | |
| 671 | + | |
| 672 | + | |
645 | 673 | | |
646 | 674 | | |
647 | 675 | | |
| |||
652 | 680 | | |
653 | 681 | | |
654 | 682 | | |
655 | | - | |
656 | | - | |
| 683 | + | |
| 684 | + | |
657 | 685 | | |
658 | 686 | | |
659 | 687 | | |
| |||
664 | 692 | | |
665 | 693 | | |
666 | 694 | | |
667 | | - | |
668 | | - | |
| 695 | + | |
| 696 | + | |
669 | 697 | | |
670 | 698 | | |
671 | 699 | | |
| |||
0 commit comments