Skip to content

Commit bd95cd6

Browse files
committed
feat(ContextMenu): open from a held finger on iOS 26's timeline
The trigger grows from 150 ms on UIKit's measured press curve, played on the compositor from the touch's own timestamp. The click haptic plays at the 400 ms commit. The menu opens at 735 ms for a finger still down, or at a lift after the commit. A lift before the commit, a second finger, a scroll, or a drift past 11.5 px on either axis before the menu gets no menu, and the trigger springs back. The commit claims the finger: no click from the lift and no page scroll under it. The page stays put while the menu is up.
1 parent 3602b8c commit bd95cd6

12 files changed

Lines changed: 1675 additions & 169 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[feat] ContextMenu opens from a held finger on iOS 26's timeline. The trigger starts to grow at 150 ms, following UIKit's measured press curve on the compositor. At 400 ms the click haptic plays where the browser can vibrate, and the press takes the finger: its lift no longer sends a click, and the page cannot scroll under it. The menu opens at 735 ms if the finger is still down, or as soon as it lifts after 400 ms. A finger that lifts before 400 ms, or drifts more than 11.5 px on either axis before the menu opens, gets no menu, and the trigger springs back. The page stays still while the menu is up, and the trigger returns to its size when the menu closes. Android's own long-press menu no longer opens a second menu.
6+
7+
@vjeux

‎apps/storybook/stories/ContextMenu.stories.tsx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,47 @@ export const InScrollContainer: Story = {
589589
</div>
590590
),
591591
};
592+
593+
const touchStyles = stylex.create({
594+
card: {
595+
width: '200px',
596+
height: '120px',
597+
display: 'grid',
598+
placeItems: 'center',
599+
borderRadius: '12px',
600+
backgroundColor: '#e5e7eb',
601+
color: '#374151',
602+
userSelect: 'none',
603+
},
604+
});
605+
606+
export const TouchLongPress: Story = {
607+
name: 'Touch / long press',
608+
parameters: {
609+
docs: {
610+
description: {
611+
story:
612+
'On a touch screen, hold a finger on the card. As on iOS, it starts to grow after 150 ms, a haptic plays at 400 ms where the device can play one, and the menu opens at 735 ms, or as soon as the finger lifts after 400 ms. A finger that lifts before 400 ms, or drifts more than 11.5 px on either axis before the menu opens, gets no menu, and the card springs back. While the menu is up the page stays still, and the card returns to its size when the menu closes.',
613+
},
614+
},
615+
},
616+
render: () => (
617+
<ContextMenu
618+
data-testid="touch-context-menu"
619+
label="Photo actions"
620+
items={[
621+
{label: 'Copy', icon: ClipboardIcon, onClick: () => {}},
622+
{label: 'Share', icon: ShareIcon, onClick: () => {}},
623+
{label: 'Save to Files', icon: ArrowDownTrayIcon, onClick: () => {}},
624+
{type: 'divider'},
625+
{
626+
label: 'Delete',
627+
icon: TrashIcon,
628+
variant: 'destructive',
629+
onClick: () => {},
630+
},
631+
]}>
632+
<div {...stylex.props(touchStyles.card)}>Hold for actions</div>
633+
</ContextMenu>
634+
),
635+
};

‎packages/cli/test/__golden__/no-icon-set/search-close.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "search",
44
"data": {
55
"query": "close",
6-
"matchCount": 44,
6+
"matchCount": 45,
77
"results": [
88
{
99
"domain": "component",

‎packages/cli/test/__golden__/no-icon-set/search-close.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Results for "close" (20 of 44)
1+
Results for "close" (20 of 45)
22
name: AlertDialog
33
domain: component
44
package: @astryxdesign/core

‎packages/core/src/ContextMenu/ContextMenu.doc.mjs‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const docs = {
160160
usage: {
161161
anatomy,
162162
description:
163-
'A right-click context menu that appears at the cursor position. Use to provide contextual actions for specific elements or regions without cluttering the UI with visible buttons.',
163+
'A right-click context menu that appears at the cursor position. Use to provide contextual actions for specific elements or regions without cluttering the UI with visible buttons. On a touch screen a held finger opens it with iOS timing: the trigger starts to grow at 150 ms, a haptic plays at 400 ms where the device can play one, and the menu opens at 735 ms, or as soon as the finger lifts after 400 ms.',
164164
bestPractices: [
165165
{
166166
guidance: true,
@@ -187,6 +187,11 @@ export const docs = {
187187
description:
188188
'Keep a visible MoreMenu or equivalent trigger for important mobile actions; long-press must not be the only route.',
189189
},
190+
{
191+
guidance: true,
192+
description:
193+
'Leave a little room around a block trigger: a held finger grows it from its center, by about 6%, until the menu closes.',
194+
},
190195
{
191196
guidance: false,
192197
description:
@@ -224,7 +229,7 @@ export const docs = {
224229
export const docsZh = {
225230
usage: {
226231
description:
227-
'右键点击时在光标位置出现的上下文菜单。用于为特定元素或区域提供上下文操作,而不使 UI 杂乱。',
232+
'右键点击时在光标位置出现的上下文菜单。用于为特定元素或区域提供上下文操作,而不使 UI 杂乱。在触摸屏上,按住手指即可打开,时序与 iOS 相同:150 毫秒时触发区域开始放大,400 毫秒时在设备支持的情况下伴随触感反馈,735 毫秒时菜单打开;若手指在 400 毫秒后抬起,菜单在抬起时立即打开。',
228233
bestPractices: [
229234
{guidance: true, description: '保持菜单项简洁和面向操作。'},
230235
{guidance: true, description: '有很多项时使用分组和分隔线。'},
@@ -242,6 +247,11 @@ export const docsZh = {
242247
description:
243248
'重要的移动端操作还应提供可见的 MoreMenu 或同等入口,不要只依赖长按。',
244249
},
250+
{
251+
guidance: true,
252+
description:
253+
'块级触发区域周围请留出少量空间:按住时它会从中心放大约 6%,直到菜单关闭。',
254+
},
245255
{
246256
guidance: false,
247257
description: '将上下文菜单作为访问重要操作的唯一方式。',
@@ -260,7 +270,7 @@ export const docsDense = {
260270
usage: {
261271
anatomy,
262272
description:
263-
'A right-click context menu that appears at the cursor position. Use to provide contextual actions for specific elements or regions.',
273+
'A right-click context menu that appears at the cursor position. Use to provide contextual actions for specific elements or regions. Touch: a held finger opens it at 735 ms, or on a lift after 400 ms (iOS timing); the trigger grows from 150 ms.',
264274
bestPractices: [
265275
{guidance: true, description: 'Keep items concise and action-oriented.'},
266276
{
@@ -281,6 +291,11 @@ export const docsDense = {
281291
guidance: true,
282292
description: 'Keep a visible mobile entry point for important actions.',
283293
},
294+
{
295+
guidance: true,
296+
description:
297+
'Leave room around a block trigger: a held finger grows it about 6%.',
298+
},
284299
{
285300
guidance: false,
286301
description: 'Use as the only way to access important actions.',

0 commit comments

Comments
 (0)