Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/menu-press-continuation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[chore] Internal: the menu press model takes a pointer that went down elsewhere, such as a context menu's long press, as the menu's opening press (`module:DropdownMenu/useMenuPress` FR11), and its trigger-less entry takes the touch model, so under the `'uikit'` touch model a finger handed to the menu, on every device, picks only past UIMenu's handoff distance. Not part of the public hooks API.

@vjeux
7 changes: 7 additions & 0 deletions .changeset/menu-press-handoff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[feature] Under a finger, on every device, the finger that opened a DropdownMenu or MoreMenu now picks a row only after it has moved 10 px (`spec:AST-094` FR29, FR43), so a menu that appears under a resting finger never picks the row beneath it, however long the finger rests. To keep the previous behavior, where that finger's lift picked once the press had lasted 300 ms, pass `presentation="popover"`. A mouse and the public `useMenuPress` hook are unchanged.

@vjeux
7 changes: 7 additions & 0 deletions .changeset/menu-press-uimenu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[feature] Under a finger, on every device, a DropdownMenu or MoreMenu trigger now opens its menu as the finger presses, instead of after a 500 ms hold (`spec:AST-094` FR29, FR43). Inside a scroll view it opens once the 150 ms content-touch delay has passed with no scroll, so a scroll that starts on it still scrolls. To keep the previous behavior, a tap that opens at the lift and a 500 ms hold, pass `presentation="popover"`. A mouse is unchanged.

@vjeux
5 changes: 4 additions & 1 deletion apps/docsite/src/__tests__/data-extraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,10 @@ describe('DropdownMenu adaptive-presentation example', () => {
);

expect(presentation?.type).toBe("'popover' | 'bottom-sheet' | 'adaptive'");
expect(presentation?.default).toBe("'popover'");
// Unset by default: the menu is anchored, with the touch modes under a
// finger. 'popover' pins the pointer behavior.
expect(presentation?.default).toBeUndefined();
expect(presentation?.description).toContain("Pass 'popover'");

const defaults = dropdownMenu?.playground?.defaults as
Record<string, unknown> | undefined;
Expand Down
28 changes: 28 additions & 0 deletions apps/storybook/stories/MenuPressContinuationA11y.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

/**
* @file MenuPressContinuationA11y.stories.tsx
* @input The menu-press continuation fixture from core's hook tests
* @output The fixture that the menu-press continuation interaction spec
* drives in a real browser. A button's finger long press opens a menu and
* hands it the held finger. Each picked row prints outside the menu.
* Excluded from the visual matrix.
* @position The reproduction path for
* `packages/core/src/hooks/__tests__/MenuPressContinuation.interaction.browser.spec.ts`.
*
* SYNC: The spec navigates to this story id by name.
*/

import type {Meta, StoryObj} from '@storybook/react';
import {ContinuedPressFixture} from '../../../packages/core/src/hooks/__tests__/menuPressContinuation.fixture';

const meta: Meta = {
title: 'a11y/Menu press continuation',
tags: ['no-visual'],
};

export default meta;

export const ContinuedPress: StoryObj = {
render: () => <ContinuedPressFixture />,
};
64 changes: 31 additions & 33 deletions docs/specs/components/DropdownMenu/DropdownMenu.spec.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/core/src/ContextMenu/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import {
import {useMenuOverflow} from '../DropdownMenu/useMenuOverflow';
import {useMenuDrillIn} from '../DropdownMenu/useMenuDrillIn';
import {useInternalListFocus} from '../hooks/useListFocus';
import {useMenuPress} from '../hooks/useMenuPress';
import {useMenuSurfacePress} from '../hooks/useMenuPress';
import {useTypeahead} from '../hooks/useTypeahead';
import {useLongPress} from '../hooks/useLongPress';
import {layerAnimations} from '../Layer/layerAnimations.stylex';
Expand Down Expand Up @@ -750,7 +750,7 @@ export function ContextMenu({
// The press model: the row under a release acts, the highlight follows a
// held pointer, a mouse released outside dismisses and a finger leaves the
// menu open.
const menuPress = useMenuPress({
const menuPress = useMenuSurfacePress({
menuRef: listRef,
itemSelector: MENU_ITEM_SELECTOR,
onDismiss: closeMenu,
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/DropdownMenu/DropdownMenu.doc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ export const docs = {
name: 'presentation',
type: "'popover' | 'bottom-sheet' | 'adaptive'",
description:
"Presentation surface for data-driven items. 'popover' stays anchored, 'bottom-sheet' always renders the actions in a modal BottomSheet, and 'adaptive' uses a BottomSheet on compact coarse-pointer layouts while remaining anchored elsewhere. Compound children currently support popover only.",
default: "'popover'",
"Presentation surface for data-driven items. 'popover' stays anchored, 'bottom-sheet' always renders the actions in a modal BottomSheet, and 'adaptive' uses a BottomSheet on compact coarse-pointer layouts while remaining anchored elsewhere. Compound children currently support popover only. Omitted, the menu is anchored, and under a finger, on every device, its trigger opens as the finger presses (inside a scroll view, after the 150 ms content-touch delay), and the opening finger picks after moving 10 px. Pass 'popover' to keep the pointer behavior on every device, a 500 ms hold included.",
},
{
name: 'isMenuOpen',
Expand Down
Loading