An open source design system that's fully customizable and agent ready
TypeScript
fix(menus): an open menu leaves pinch-zoom to the browser (#7201)
Christopher Chedeau904341cb4b1b
diff --git a/.changeset/menu-pinch-zoom.md b/.changeset/menu-pinch-zoom.mdnew file mode 100644index 0000000000..5d07bb81ec--- /dev/null+++ b/.changeset/menu-pinch-zoom.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] A two-finger pinch over an open DropdownMenu, sub-menu flyout, ContextMenu or Selector list now zooms the page. The menus declared `touch-action: none` while their rows fit and `pan-y` once they scroll, and neither allows a pinch, so a phone could not zoom the page while a menu was open. They now declare `pinch-zoom` and `pan-y pinch-zoom`; a one-finger slide over the rows and the press model behave as before.++@vjeuxdiff --git a/packages/core/src/ContextMenu/ContextMenu.tsx b/packages/core/src/ContextMenu/ContextMenu.tsxindex 6c9d9ebc05..b731e37211 100644--- a/packages/core/src/ContextMenu/ContextMenu.tsx+++ b/packages/core/src/ContextMenu/ContextMenu.tsx@@ -145,11 +145,11 @@ const styles = stylex.create({WebkitTouchCallout: 'none',},// Scroll ownership by the browser's own signal; see DropdownMenu.- touchNone: {- touchAction: 'none',+ touchPinchZoom: {+ touchAction: 'pinch-zoom',},- touchPanY: {- touchAction: 'pan-y',+ touchPanYPinchZoom: {+ touchAction: 'pan-y pinch-zoom',overscrollBehavior: 'contain',},popover: {@@ -659,7 +659,7 @@ export function ContextMenu({stylex.props(usesBottomSheet ? styles.sheetMenu : styles.menu,!usesBottomSheet &&- (hasOverflow ? styles.touchPanY : styles.touchNone),+ (hasOverflow ? styles.touchPanYPinchZoom : styles.touchPinchZoom),xstyle,),className,diff --git a/packages/core/src/DropdownMenu/DropdownMenu.test.tsx b/packages/core/src/DropdownMenu/DropdownMenu.test.tsxindex 8e86041180..a1488a2774 100644--- a/packages/core/src/DropdownMenu/DropdownMenu.test.tsx+++ b/packages/core/src/DropdownMenu/DropdownMenu.test.tsx@@ -2640,12 +2640,16 @@ describe('DropdownMenu press model', () => {// dev build prefixes a debug name; the hash is the last token).const touchStyles = stylex.create({none: {touchAction: 'none'},- panY: {touchAction: 'pan-y'},+ pinchZoom: {touchAction: 'pinch-zoom'},+ panYPinchZoom: {touchAction: 'pan-y pinch-zoom'},});const hash = (style: stylex.StyleXStyles) =>stylex.props(style).className!.split(' ').pop()!;- expect(menu).toHaveClass(hash(touchStyles.none));- expect(menu).not.toHaveClass(hash(touchStyles.panY));+ // Rows that fit keep every one-finger move and leave a pinch to the+ // browser, so the page stays zoomable over the open menu.+ expect(menu).toHaveClass(hash(touchStyles.pinchZoom));+ expect(menu).not.toHaveClass(hash(touchStyles.none));+ expect(menu).not.toHaveClass(hash(touchStyles.panYPinchZoom));});it('a mouse press on the trigger opens the menu and a drag-release acts on the row under it', () => {diff --git a/packages/core/src/DropdownMenu/DropdownMenu.tsx b/packages/core/src/DropdownMenu/DropdownMenu.tsxindex edfdbcaac0..3b2515eacc 100644--- a/packages/core/src/DropdownMenu/DropdownMenu.tsx+++ b/packages/core/src/DropdownMenu/DropdownMenu.tsx@@ -151,13 +151,15 @@ const styles = stylex.create({overscrollBehavior: 'contain',},// Scroll ownership by the browser's own signal. A menu whose rows fit keeps- // every finger: a slide over its rows stays a slide. One that scrolls lets- // the browser pan it vertically and cancel the press when it does.- touchNone: {- touchAction: 'none',+ // every one-finger move: a slide over its rows stays a slide. One that+ // scrolls lets the browser pan it vertically and cancel the press when it+ // does. Both leave a two-finger pinch to the browser, so the page stays+ // zoomable over an open menu; `pinch-zoom` admits no one-finger pan.+ touchPinchZoom: {+ touchAction: 'pinch-zoom',},- touchPanY: {- touchAction: 'pan-y',+ touchPanYPinchZoom: {+ touchAction: 'pan-y pinch-zoom',overscrollBehavior: 'contain',},// The menu's lower block cap rides on the layer box too, so the layer's@@ -1332,7 +1334,7 @@ function DropdownMenuPopover({styles.dropdown,resolvedMaxHeight != null &&dynamicStyles.menuMaxHeight(resolvedMaxHeight),- hasOverflow ? styles.touchPanY : styles.touchNone,+ hasOverflow ? styles.touchPanYPinchZoom : styles.touchPinchZoom,hasOverflow && styles.scrollable,xstyle,),diff --git a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsxindex dcd1443bb6..c30ca3b7d1 100644--- a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx+++ b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx@@ -194,11 +194,11 @@ const flyoutStyles = stylex.create({overscrollBehavior: 'contain',},// Scroll ownership by the browser's own signal; see DropdownMenu.- touchNone: {- touchAction: 'none',+ touchPinchZoom: {+ touchAction: 'pinch-zoom',},- touchPanY: {- touchAction: 'pan-y',+ touchPanYPinchZoom: {+ touchAction: 'pan-y pinch-zoom',overscrollBehavior: 'contain',},popoverViewport: {@@ -886,7 +886,9 @@ export function DropdownMenuSubMenu(themeProps('dropdown-menu'),stylex.props(flyoutStyles.menu,- hasOverflow ? flyoutStyles.touchPanY : flyoutStyles.touchNone,+ hasOverflow+ ? flyoutStyles.touchPanYPinchZoom+ : flyoutStyles.touchPinchZoom,hasOverflow && flyoutStyles.scrollable,),)}>diff --git a/packages/core/src/DropdownMenu/__tests__/MenuPinchZoom.a11y.chromium.spec.ts b/packages/core/src/DropdownMenu/__tests__/MenuPinchZoom.a11y.chromium.spec.tsnew file mode 100644index 0000000000..18087a9a5f--- /dev/null+++ b/packages/core/src/DropdownMenu/__tests__/MenuPinchZoom.a11y.chromium.spec.ts@@ -0,0 +1,172 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file MenuPinchZoom.a11y.chromium.spec.ts+ * @input Built DropdownMenu and Selector stories and real Chromium touch+ * input (CDP) on a phone profile+ * @output Browser evidence that a two-finger pinch over an open menu, one+ * whose rows fit or one that scrolls, or over an open picker listbox, zooms+ * the page (WCAG 1.4.4) and acts on no row+ * @position Real-engine proof for the pinch half of+ * module:DropdownMenu/useMenuPress FR4; jsdom computes no touch-action+ */++import {+ expect,+ test,+ type CDPSession,+ type Locator,+ type Page,+} from '@playwright/test';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';++let storybook: StaticServer;+test.beforeAll(async () => {+ storybook = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+});+test.afterAll(async () => {+ await storybook?.close();+});++// A phone: the viewport meta applies and the page can pinch-zoom.+test.use({+ hasTouch: true,+ isMobile: true,+ viewport: {width: 390, height: 844},+ deviceScaleFactor: 3,+});++const sleep = async (ms: number) =>+ new Promise(resolve => setTimeout(resolve, ms));++async function mount(page: Page, story: string) {+ await page.goto(`${storybook.origin}/iframe.html?id=${story}&viewMode=story`);+ await expect(page.locator('#storybook-root')).toBeVisible();+}++async function pageScale(page: Page) {+ return page.evaluate(() => window.visualViewport?.scale ?? 1);+}++async function centerOf(locator: Locator) {+ const box = await locator.boundingBox();+ if (box == null) {+ throw new Error('no rendered bounds');+ }+ return {x: box.x + box.width / 2, y: box.y + box.height / 2};+}++type Point = {x: number; y: number};++// Two fingers land one after the other and spread apart sideways, as a person+// pinches. Sideways, because a menu that scrolls pans vertically: a vertical+// spread would spend its first stretch panning before the zoom takes over.+async function pinch(cdp: CDPSession, at: Point) {+ const first = {x: at.x - 30, y: at.y};+ const second = {x: at.x + 30, y: at.y};+ const steps = 12;+ const spread = 3;+ const point = (p: Point, k: number, id: number) => ({+ x: at.x + (p.x - at.x) * k,+ y: at.y + (p.y - at.y) * k,+ id,+ });+ await cdp.send('Input.dispatchTouchEvent', {+ type: 'touchStart',+ touchPoints: [point(first, 1, 1)],+ });+ await sleep(30);+ await cdp.send('Input.dispatchTouchEvent', {+ type: 'touchStart',+ touchPoints: [point(first, 1, 1), point(second, 1, 2)],+ });+ for (let i = 1; i <= steps; i++) {+ await sleep(16);+ const k = 1 + ((spread - 1) * i) / steps;+ await cdp.send('Input.dispatchTouchEvent', {+ type: 'touchMove',+ touchPoints: [point(first, k, 1), point(second, k, 2)],+ });+ }+ await sleep(16);+ await cdp.send('Input.dispatchTouchEvent', {+ type: 'touchEnd',+ touchPoints: [],+ });+ await sleep(600);+}++test('a pinch over an open menu whose rows fit zooms the page and acts on no row', async ({+ page,+}) => {+ // The story's rows log `<label> clicked`; that line is an activation.+ const activations: string[] = [];+ page.on('console', message => {+ if (message.text().endsWith(' clicked')) {+ activations.push(message.text());+ }+ });+ await mount(page, 'core-dropdownmenu--default');+ await page.getByRole('button', {name: 'Actions'}).tap();+ const menu = page.getByRole('menu');+ await expect(menu).toBeVisible();+ expect(await pageScale(page)).toBe(1);++ const cdp = await page.context().newCDPSession(page);+ await pinch(+ cdp,+ await centerOf(page.getByRole('menuitem', {name: 'Duplicate'})),+ );++ expect(await pageScale(page)).toBeGreaterThan(1.2);+ expect(activations).toEqual([]);+});++test('a pinch over an open menu that scrolls zooms the page and acts on no row', async ({+ page,+}) => {+ await mount(page, 'core-dropdownmenu--tall-content-overflow');+ const menu = page.getByRole('menu');+ // The story's play opens the menu; open it here if it has not.+ await menu.waitFor({state: 'visible', timeout: 3000}).catch(async () => {+ await page.getByRole('button', {name: 'Move to project'}).tap();+ });+ await expect(menu).toBeVisible();+ await expect+ .poll(async () =>+ menu.evaluate(el => el.scrollHeight > el.clientHeight + 1),+ )+ .toBe(true);+ expect(await pageScale(page)).toBe(1);++ const cdp = await page.context().newCDPSession(page);+ await pinch(cdp, await centerOf(menu));++ expect(await pageScale(page)).toBeGreaterThan(1.2);+ // A row that acted would have closed the menu.+ await expect(menu).toBeVisible();+});++test('a pinch over an open picker listbox zooms the page and selects nothing', async ({+ page,+}) => {+ await mount(page, 'core-selector--default');+ const combobox = page.getByRole('combobox');+ await combobox.tap();+ const listbox = page.getByRole('listbox');+ await expect(listbox).toBeVisible();+ expect(await pageScale(page)).toBe(1);++ const cdp = await page.context().newCDPSession(page);+ await pinch(cdp, await centerOf(page.getByRole('option', {name: 'Banana'})));++ expect(await pageScale(page)).toBeGreaterThan(1.2);+ await expect(listbox).toBeVisible();+ await expect(combobox).not.toContainText('Banana');+});diff --git a/packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts b/packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.tsindex edbe1e3f88..273d589aba 100644--- a/packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts+++ b/packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts@@ -379,7 +379,7 @@ test.describe('DropdownMenu press model (Chromium)', () => {.toBe(true);await expect.poll(async () => menu.evaluate(el => getComputedStyle(el).touchAction))- .toBe('pan-y');+ .toBe('pan-y pinch-zoom');const first = await center(page, 'menuitem', 'New File');const scrollBefore = await menu.evaluate(el => el.scrollTop);@@ -394,7 +394,7 @@ test.describe('DropdownMenu press model (Chromium)', () => {await expect(menu).toBeVisible();});- test('touch: a menu whose rows fit declares touch-action none, so a slide stays a slide', async ({+ test('touch: a menu whose rows fit declares touch-action pinch-zoom, so a slide stays a slide', async ({page,}) => {await enableTouch(page);@@ -403,7 +403,7 @@ test.describe('DropdownMenu press model (Chromium)', () => {const menu = page.getByRole('menu');await expect.poll(async () => menu.evaluate(el => getComputedStyle(el).touchAction))- .toBe('none');+ .toBe('pinch-zoom');});test('pen: a drag released over another row acts on it once; a release outside leaves the menu open', async ({diff --git a/packages/core/src/DropdownMenu/modules/useMenuPress.spec.md b/packages/core/src/DropdownMenu/modules/useMenuPress.spec.mdindex d45204af43..756a67458b 100644--- a/packages/core/src/DropdownMenu/modules/useMenuPress.spec.md+++ b/packages/core/src/DropdownMenu/modules/useMenuPress.spec.md@@ -19,6 +19,7 @@ verified_by:packages/core/src/ContextMenu/ContextMenu.test.tsx,packages/core/src/Selector/Selector.test.tsx,packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts,+ packages/core/src/DropdownMenu/__tests__/MenuPinchZoom.a11y.chromium.spec.ts,]parent_component: component:DropdownMenureferences:@@ -144,17 +145,17 @@ Consumer migration instructions belong in consumer docs and release notes.## Behavioral contract-| ID | Invariant | Basis | Verification state |-| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- | ------------------------------ |-| FR1 | A row MUST act when a press is released over it, never because the press began on it. A press that never left its row is a tap and acts on that row. | macOS and iOS menu behavior; `menuPressGesture.test.ts`, `useMenuPress.test.tsx` | verify |-| FR2 | While a press is held inside a menu, the highlighted row MUST be the enabled row under the pointer, and nothing MUST be highlighted over a divider, a heading, a disabled row, or outside the menu. A mouse moving with no button down moves the highlight the same way (existing hover-to-focus). | `architecture:interaction-modality` allowed variation for menus; `useMenuPress.test.tsx` | verify |-| FR3 | A press that began inside a menu and is released outside it MUST act on nothing. Under a mouse the menu MUST then close; under a finger or pen it MUST stay open. | DEC-3; `useMenuPress.test.tsx`, `DropdownMenu.test.tsx`, `Selector.test.tsx` | verify |-| FR4 | A menu whose rows fit MUST declare `touch-action: none`; one that scrolls MUST declare `touch-action: pan-y` and `overscroll-behavior: contain`. The model MUST treat `pointercancel` and a second pointer as the end of the gesture with nothing acting, and MUST NOT re-implement scrolling. | Browser scroll ownership; `DropdownMenu.test.tsx` touch-action case, `useMenuPress.test.tsx` | verify |-| FR5 | The click the browser reports for a gesture this model tracked MUST NOT act on any row; only the release acts. A click with no tracked gesture behind it, or one whose `detail` is 0, MUST act on its target as before. The swallower arms at a tracked release and disarms at the next `pointerdown` or after the stray-click window. | One gesture, one activation; `useMenuPress.test.tsx` FR5 suite | verify |-| FR6 | At most one row of a menu is lit. Under a finger the row a press began on MUST NOT keep a pressed or hovered look once the pointer left it, so menu rows paint `:active` only under `(hover: hover)`. | `DropdownMenuItem.tsx` styles | verify |-| FR7 | While a press is tracked in a menu that scrolls, a pointer resting within the edge zone of the menu's top or bottom MUST scroll the menu toward that edge and re-read the row under the pointer as the rows move. | `useMenuPress.test.tsx` autoscroll case | verify |-| FR8 | On a mouse a DropdownMenu trigger MUST open its menu on press-down (button 0, no Control), and a drag from the trigger into the menu that releases over an enabled row MUST act on it. The opening gesture's release MUST act only if the pointer entered the menu or the press lasted the settle time; otherwise nothing acts and the menu stays open. Pressing the trigger of an open menu MUST close it and MUST NOT reopen it in the same gesture. | Proposed DEC-4; `DropdownMenu.test.tsx` press model suite, `menuPressGesture.test.ts` trigger states | proposed; pending owner review |-| FR9 | Under a finger a tap on the trigger MUST open the menu through its click. A press held on the trigger for the long-press delay MUST open the menu with the finger down, prevent the default of the finger's later `touchmove`s until the gesture ends, and continue under FR1–FR4 with the same settle rule. | Proposed DEC-4; `DropdownMenu.test.tsx` held-touch case, `useMenuPress.test.tsx` | proposed; pending owner review |+| ID | Invariant | Basis | Verification state |+| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |+| FR1 | A row MUST act when a press is released over it, never because the press began on it. A press that never left its row is a tap and acts on that row. | macOS and iOS menu behavior; `menuPressGesture.test.ts`, `useMenuPress.test.tsx` | verify |+| FR2 | While a press is held inside a menu, the highlighted row MUST be the enabled row under the pointer, and nothing MUST be highlighted over a divider, a heading, a disabled row, or outside the menu. A mouse moving with no button down moves the highlight the same way (existing hover-to-focus). | `architecture:interaction-modality` allowed variation for menus; `useMenuPress.test.tsx` | verify |+| FR3 | A press that began inside a menu and is released outside it MUST act on nothing. Under a mouse the menu MUST then close; under a finger or pen it MUST stay open. | DEC-3; `useMenuPress.test.tsx`, `DropdownMenu.test.tsx`, `Selector.test.tsx` | verify |+| FR4 | A menu whose rows fit MUST declare `touch-action: pinch-zoom`; one that scrolls MUST declare `touch-action: pan-y pinch-zoom` and `overscroll-behavior: contain`. Neither admits a one-finger pan the menu does not scroll, and both leave a two-finger pinch to the browser, so the page stays zoomable over an open menu. The model MUST treat `pointercancel` and a second pointer as the end of the gesture with nothing acting, and MUST NOT re-implement scrolling. | Browser scroll ownership; WCAG 2.2 SC 1.4.4 under `spec:AST-020` FR1; `DropdownMenu.test.tsx` touch-action case, `useMenuPress.test.tsx`, `MenuPinchZoom.a11y.chromium.spec.ts` | verify |+| FR5 | The click the browser reports for a gesture this model tracked MUST NOT act on any row; only the release acts. A click with no tracked gesture behind it, or one whose `detail` is 0, MUST act on its target as before. The swallower arms at a tracked release and disarms at the next `pointerdown` or after the stray-click window. | One gesture, one activation; `useMenuPress.test.tsx` FR5 suite | verify |+| FR6 | At most one row of a menu is lit. Under a finger the row a press began on MUST NOT keep a pressed or hovered look once the pointer left it, so menu rows paint `:active` only under `(hover: hover)`. | `DropdownMenuItem.tsx` styles | verify |+| FR7 | While a press is tracked in a menu that scrolls, a pointer resting within the edge zone of the menu's top or bottom MUST scroll the menu toward that edge and re-read the row under the pointer as the rows move. | `useMenuPress.test.tsx` autoscroll case | verify |+| FR8 | On a mouse a DropdownMenu trigger MUST open its menu on press-down (button 0, no Control), and a drag from the trigger into the menu that releases over an enabled row MUST act on it. The opening gesture's release MUST act only if the pointer entered the menu or the press lasted the settle time; otherwise nothing acts and the menu stays open. Pressing the trigger of an open menu MUST close it and MUST NOT reopen it in the same gesture. | Proposed DEC-4; `DropdownMenu.test.tsx` press model suite, `menuPressGesture.test.ts` trigger states | proposed; pending owner review |+| FR9 | Under a finger a tap on the trigger MUST open the menu through its click. A press held on the trigger for the long-press delay MUST open the menu with the finger down, prevent the default of the finger's later `touchmove`s until the gesture ends, and continue under FR1–FR4 with the same settle rule. | Proposed DEC-4; `DropdownMenu.test.tsx` held-touch case, `useMenuPress.test.tsx` | proposed; pending owner review |### Transformation and precedence order@@ -235,6 +236,7 @@ owned by the item components.| FR1, FR3–FR5 | `DropdownMenu.test.tsx`, `DropdownMenuSubMenu.test.tsx`, `ContextMenu.test.tsx` press suites | finger slide across rows, outside release by mouse and finger, `touch-action`, flyout release, root marker | Each removed behavior fails its named case || FR1, FR3, AR2 | `Selector.test.tsx` press model suite | finger release over another option, finger/mouse release outside, listbox marker | A listbox that takes focus, acts on the press option, or closes under a finger fails || FR4 (scroll) | `MenuPress.a11y.chromium.spec.ts` (real Chromium) | Chromium touch pan in an overflowing menu; touch-action by overflow; finger slide and its stray click | Not provable in jsdom; a pan that acts on a row, or a slide that acts on the press row, fails |+| FR4 (pinch) | `MenuPinchZoom.a11y.chromium.spec.ts` (real Chromium, phone emulation) | two-finger pinch over a menu whose rows fit, over one that scrolls, and over a picker listbox | Not provable in jsdom; a pinch that leaves the page at scale 1, or acts on a row, fails || FR8, FR9 (proposed) | `menuPressGesture.test.ts` trigger states; `useMenuPress.test.tsx` trigger suite; `DropdownMenu.test.tsx` press-open cases | mouse opens at once, finger tap, held finger, settle before/after, cancel; press-open + drag-release, unsettled release, trigger toggle, held touch, tap | A menu that does not open on a mouse press, an unsettled release that acts, or a trigger that reopens in the same gesture fails |## Decision logdiff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsxindex 41c29fd626..5f2a855c0d 100644--- a/packages/core/src/Selector/Selector.test.tsx+++ b/packages/core/src/Selector/Selector.test.tsx@@ -4581,7 +4581,7 @@ describe('Selector press model', () => {}});- it('the listbox owns touch scrolling: touch-action none while the options fit', async () => {+ it('the listbox owns touch scrolling: touch-action pinch-zoom while the options fit', async () => {const user = userEvent.setup();render(<Selector label="Fruit" options={OPTIONS} onChange={() => {}} />);await user.click(screen.getByRole('combobox'));@@ -4591,12 +4591,14 @@ describe('Selector press model', () => {// build prefixes a debug name; the hash is the last token).const touchStyles = stylex.create({none: {touchAction: 'none'},- panY: {touchAction: 'pan-y'},+ pinchZoom: {touchAction: 'pinch-zoom'},+ panYPinchZoom: {touchAction: 'pan-y pinch-zoom'},});const hash = (style: stylex.StyleXStyles) =>stylex.props(style).className!.split(' ').pop()!;- expect(listbox).toHaveClass(hash(touchStyles.none));- expect(listbox).not.toHaveClass(hash(touchStyles.panY));+ expect(listbox).toHaveClass(hash(touchStyles.pinchZoom));+ expect(listbox).not.toHaveClass(hash(touchStyles.none));+ expect(listbox).not.toHaveClass(hash(touchStyles.panYPinchZoom));});it('marks the listbox as carrying the press model', async () => {diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsxindex 3583931513..0ca3f630c0 100644--- a/packages/core/src/Selector/Selector.tsx+++ b/packages/core/src/Selector/Selector.tsx@@ -310,14 +310,15 @@ const styles = stylex.create({paddingInline: `calc(${spacingVars['--spacing-1']} + ${borderVars['--border-width']})`,},// Scroll ownership by the browser's own signal, as the menus declare it: a- // list whose options fit keeps every finger, so a slide over the options- // stays a slide; one that scrolls lets the browser pan it vertically and- // cancel the press when it does.- touchNone: {- touchAction: 'none',+ // list whose options fit keeps every one-finger move, so a slide over the+ // options stays a slide; one that scrolls lets the browser pan it vertically+ // and cancel the press when it does. Both leave a two-finger pinch to the+ // browser, so the page stays zoomable over an open list.+ touchPinchZoom: {+ touchAction: 'pinch-zoom',},- touchPanY: {- touchAction: 'pan-y',+ touchPanYPinchZoom: {+ touchAction: 'pan-y pinch-zoom',overscrollBehavior: 'contain',},// Same correction for the search row's gutter, so the search field and the@@ -1704,7 +1705,9 @@ export function Selector<T extends SelectorOptionType>({...listboxPress.menuProps}{...stylex.props(styles.dropdown,- listboxHasOverflow ? styles.touchPanY : styles.touchNone,+ listboxHasOverflow+ ? styles.touchPanYPinchZoom+ : styles.touchPinchZoom,surface.activePresentation === 'popover' &&variant !== 'ghost' &&styles.dropdownInput,@@ -1742,7 +1745,7 @@ export function Selector<T extends SelectorOptionType>(}{...stylex.props(styles.dropdown,- listboxHasOverflow ? styles.touchPanY : styles.touchNone,+ listboxHasOverflow ? styles.touchPanYPinchZoom : styles.touchPinchZoom,surface.activePresentation === 'popover' &&variant !== 'ghost' &&styles.dropdownInput,diff --git a/packages/core/src/hooks/useMenuPress.doc.mjs b/packages/core/src/hooks/useMenuPress.doc.mjsindex 25743c24e3..b860c2de93 100644--- a/packages/core/src/hooks/useMenuPress.doc.mjs+++ b/packages/core/src/hooks/useMenuPress.doc.mjs@@ -132,7 +132,7 @@ export const docs = {{guidance: true,description:- 'Declare touch-action on the menu root: none when its rows fit, pan-y when it scrolls, so the browser — not the hook — decides when a finger is scrolling.',+ 'Declare touch-action on the menu root: pinch-zoom when its rows fit, pan-y pinch-zoom when it scrolls, so the browser — not the hook — decides when a finger is scrolling, and a two-finger pinch still zooms the page.',},{guidance: false,@@ -196,7 +196,7 @@ export const docsDense = {{guidance: true,description:- 'touch-action on the root: none when rows fit, pan-y when it scrolls.',+ 'touch-action on the root: pinch-zoom when rows fit, pan-y pinch-zoom when it scrolls.',},{guidance: false,