Skip to content

Commit e3c7fa5

Browse files
committed
test(useMenuPress): a continued finger's handoff follows the touch model on every device (spec:AST-094 FR43)
Under FR43 the press model keys a finger on the touch model, which DropdownMenu takes from its presentation, not from the primary pointer. The continuation's doc comment, its code comment and two test names now say "touch model" where they said coarse or fine pointer. The interaction fixture runs the 'uikit' model, as DropdownMenu's default presentation does, instead of reading the coarse-pointer query. Behavior does not change: the spec drives a finger through a touch device, where the query read 'uikit' already.
1 parent 1d478c2 commit e3c7fa5

4 files changed

Lines changed: 22 additions & 23 deletions

File tree

‎packages/core/src/hooks/__tests__/MenuPressContinuation.interaction.browser.spec.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* (Chromium CDP / WebKit's input command), the interaction harness, and the
77
* menu press's handoff distance from the UIKit constants table
88
* @output Interaction proofs for a pointer handed to a menu as it opens
9-
* (`module:DropdownMenu/useMenuPress` FR11), under a finger where the
10-
* primary pointer is coarse: held on a button until the menu opens under
11-
* it, the finger picks the row it lifts on only once it has travelled the
9+
* (`module:DropdownMenu/useMenuPress` FR11), under a finger (the same on
10+
* every device, `spec:AST-094` FR43): held on a button until the menu opens
11+
* under it, the finger picks the row it lifts on only once it has travelled the
1212
* handoff distance from the first position the menu sees; a lift before
1313
* that acts on nothing and leaves the menu open
1414
* @position The real-browser case FR11's verification names, beside the

‎packages/core/src/hooks/__tests__/menuPressContinuation.fixture.tsx‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
/**
66
* @file menuPressContinuation.fixture.tsx
7-
* @input useMenuSurfacePress (its continueGesture), useMediaQuery and the
8-
* coarse-pointer query
7+
* @input useMenuSurfacePress (its continueGesture)
98
* @output ContinuedPressFixture: a plain button whose finger long press opens
109
* a list menu under the held finger and hands that finger to the menu's
1110
* press model (`module:DropdownMenu/useMenuPress` FR11), with each picked
@@ -21,8 +20,6 @@
2120

2221
import {useEffect, useRef, useState} from 'react';
2322
import {useMenuSurfacePress, type MenuPressContinuation} from '../useMenuPress';
24-
import {useMediaQuery} from '../useMediaQuery';
25-
import {TOUCH_QUERY} from '../../utils/touchPresentation';
2623
import {
2724
CONTINUED_PRESS_HOLD_MS,
2825
CONTINUED_PRESS_ROWS,
@@ -33,14 +30,14 @@ export function ContinuedPressFixture() {
3330
const menuRef = useRef<HTMLDivElement>(null);
3431
const [isOpen, setIsOpen] = useState(false);
3532
const [picked, setPicked] = useState<ReadonlyArray<string>>([]);
36-
// The touch model the press model needs for FR11's handoff: as
37-
// DropdownMenu does, 'uikit' where the primary pointer is coarse.
38-
const isCoarse = useMediaQuery(TOUCH_QUERY, false);
33+
// The touch model the press model needs for FR11's handoff: 'uikit', as
34+
// DropdownMenu's default presentation runs it for a finger on every device
35+
// (`spec:AST-094` FR43).
3936
const press = useMenuSurfacePress({
4037
menuRef,
4138
itemSelector: '[role="menuitem"]',
4239
onDismiss: () => setIsOpen(false),
43-
touchModel: isCoarse ? 'uikit' : 'pointer',
40+
touchModel: 'uikit',
4441
});
4542
const holdTimerRef = useRef<number | null>(null);
4643
const handOffRef = useRef<MenuPressContinuation | null>(null);

‎packages/core/src/hooks/useMenuPress.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ describe('useMenuPress — the trigger', () => {
568568
};
569569
const finger = {pointerType: 'touch', pointerId: 7};
570570

571-
it('where the primary pointer is coarse, a finger picks only after the handoff distance from the first position the menu sees', () => {
571+
it("with the 'uikit' touch model (a finger, on every device: FR43), a finger picks only after the handoff distance from the first position the menu sees", () => {
572572
const onSelect = vi.fn();
573573
const press: {current: DropdownMenuPressReturn | null} = {current: null};
574574
render(
@@ -584,7 +584,7 @@ describe('useMenuPress — the trigger', () => {
584584
expect(onSelect).toHaveBeenCalledWith('B');
585585
});
586586

587-
it('where the primary pointer is fine, a handed-off finger is the opening press under the settle rule: no handoff distance', () => {
587+
it('with the \'pointer\' touch model (presentation="popover"), a handed-off finger is the opening press under the settle rule: no handoff distance', () => {
588588
const onSelect = vi.fn();
589589
const press: {current: DropdownMenuPressReturn | null} = {current: null};
590590
render(<Harness onSelect={onSelect} pressRef={press} />);

‎packages/core/src/hooks/useMenuPress.ts‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,14 @@ export interface DropdownMenuPressReturn extends UseMenuPressReturn {
266266
* a trigger this hook does not own) into the menu that just opened under
267267
* it. The pointer is tracked from here as the opening press
268268
* (`module:DropdownMenu/useMenuPress` FR11). With the `'uikit'` touch model
269-
* (the primary pointer is coarse) a finger picks only after UIMenu's handoff
270-
* distance from the first position the menu sees after it opened, as a
271-
* trigger's opening finger does, and its lift before that acts on nothing and
272-
* leaves the menu open; otherwise, and for a mouse, the opening press follows
273-
* the settle rule. Ignored while another gesture is live or the hook is
274-
* disabled. A menu with no trigger (a context menu) passes the touch model
275-
* to `useMenuSurfacePress`, so the finger it hands over keeps the handoff.
269+
* (a finger, on every device: `spec:AST-094` FR43) a finger picks only after
270+
* UIMenu's handoff distance from the first position the menu sees after it
271+
* opened, as a trigger's opening finger does, and its lift before that acts
272+
* on nothing and leaves the menu open; otherwise, and for a mouse, the
273+
* opening press follows the settle rule. Ignored while another gesture is
274+
* live or the hook is disabled. A menu with no trigger (a context menu)
275+
* passes the touch model to `useMenuSurfacePress`, so the finger it hands
276+
* over keeps the handoff.
276277
*/
277278
continueGesture: (pointer: MenuPressContinuation) => void;
278279
}
@@ -990,9 +991,10 @@ function useMenuPressModel(options: DropdownMenuPressOptions): {
990991
}
991992
attach(pointer.pointerId);
992993
// The menu opened under this pointer: the gesture is the opening press.
993-
// Where the primary pointer is coarse a finger's handoff counts from the
994-
// first position the menu sees after it opened, as the trigger's opening
995-
// finger's does; elsewhere the settle rule decides its release.
994+
// With the 'uikit' touch model a finger's handoff counts from the first
995+
// position the menu sees after it opened, as the trigger's opening
996+
// finger's does; with the 'pointer' model, and for a mouse, the settle
997+
// rule decides its release.
996998
gestureRef.current = {
997999
phase: 'open',
9981000
pointerType: pointer.pointerType,

0 commit comments

Comments
 (0)