Commit ef2aad7
authored
fix(context-menu): keep menu open after long-press release on touch (tldraw#8741)
In order to make the long-press context menu usable on touch devices,
this PR fixes a bug where the menu opened on iOS but closed the moment
the user lifted their finger (tldraw#8740).
Radix's `ContextMenu` Trigger has its own 700ms touch long-press
detection that is independent of tldraw's `long_press` event. When that
timer fires, the menu opens while the same touch is still down. The
pointerup that follows is read by the dismissable layer as an outside
interaction and dismisses the menu before the user can choose anything.
The fix swallows outside-interaction dismissals during a 500ms grace
window after the menu opens, but only on coarse pointers — desktop
right-click is untouched.
### Change type
- [x] `bugfix`
### Test plan
1. On iOS Safari (or a touch-emulated browser), long-press the canvas in
the examples app or on tldraw.com.
2. Confirm the context menu opens and stays open after the finger is
lifted.
3. Tap a menu item; confirm the action runs and the menu closes.
4. Tap somewhere outside the menu (a fresh touch) and confirm the menu
dismisses.
5. On desktop, right-click the canvas; confirm the menu opens, an item
can be selected, and an outside click dismisses it normally.
- [ ] Unit tests
- [ ] End to end tests
### Release notes
- Fix the iOS context menu closing immediately after a long-press
release.
### Code changes
| Section | LOC change |
| --------- | ---------- |
| Core code | +20 / -2 |1 parent bf660a7 commit ef2aad7
1 file changed
Lines changed: 20 additions & 2 deletions
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
| |||
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
67 | | - | |
68 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
| |||
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
| |||
0 commit comments