Skip to content

Commit 14915e9

Browse files
committed
Merge meta#8083 (f1c34bf: the actions' row takes no text selection) into meta#8084
2 parents 9606c5c + f1c34bf commit 14915e9

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

‎packages/core/src/AlertDialog/AlertDialog.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,14 @@ const styles = stylex.create({
6969
// a long press does: the browser may pinch-zoom there but never pans (Chrome
7070
// on Android cancels a pointer it pans, which would cancel the group's
7171
// press), and a double tap zooms nothing (`spec:AST-094` FR18: the gesture
72-
// host never allows more than this).
72+
// host never allows more than this). A press that slides across the
73+
// actions selects none of their labels, for a mouse too (`spec:AST-094`
74+
// FR41: the hold does something); the title and the message stay
75+
// selectable.
7376
trackingRow: {
7477
touchAction: 'pinch-zoom',
78+
userSelect: 'none',
79+
WebkitUserSelect: 'none',
7580
},
7681
// UIKit's alert motion drives the dialog (useAlertMotion): the theme's
7782
// entrance keyframes stand down.

‎packages/core/src/AlertDialog/__tests__/AlertDialog.interaction.browser.spec.ts‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
* off both; only the actions are tracked, so a touch that lands on the
1313
* message runs nothing; a tap and a mouse click run their action once; a
1414
* mouse is tracked too, so its slide from Delete to Cancel runs Cancel; a
15-
* held finger starts no text selection (refused by style or by a cancelled
16-
* selectstart); the tracking is the same under a finger in Chrome's engine;
15+
* press on the actions selects none of their labels while the title and
16+
* the message stay selectable; the tracking is the same under a finger in
17+
* Chrome's engine;
1718
* a storyboard of the slide from Delete to Cancel.
1819
* @position Touch lane of AlertDialog, beside the accessibility bindings in
1920
* this folder. Run with `pnpm test:interaction AlertDialog`.
@@ -226,43 +227,38 @@ test('a lift off both actions runs nothing and leaves the alert open', async ({
226227
expect((await readLog(page)).clicks).toEqual([]);
227228
});
228229

229-
test('a held finger starts no text selection: a selection is refused while it is down, and allowed again after', async ({
230+
test('a press on the actions starts no text selection, by style, while the title and the message stay selectable (spec:AST-094 FR41)', async ({
230231
page,
231232
}) => {
232233
const {driver, dialog, del, centers, bottom} = await openAlert(page);
233-
// The lock refuses a selection one of two ways (spec:AST-094 FR41): where
234-
// iOS WebKit runs, `user-select: none` on the held group; elsewhere a
235-
// cancelled `selectstart` on the text under the finger, with no style
236-
// write. Either is a refusal; with neither, the text is selectable. The
237-
// group is the actions' row, so that is where the lock applies.
238-
const row = del.locator('..');
239-
const refusesSelection = async () => {
240-
const userSelect = await row.evaluate(element => {
234+
const userSelect = async (locator: Locator) =>
235+
locator.evaluate(element => {
241236
const style = getComputedStyle(element);
242237
return (
243238
style.getPropertyValue('user-select') ||
244239
style.getPropertyValue('-webkit-user-select')
245240
);
246241
});
247-
const isCancelled = await del.evaluate(element => {
248-
const start = new Event('selectstart', {bubbles: true, cancelable: true});
249-
element.dispatchEvent(start);
250-
return start.defaultPrevented;
251-
});
252-
return userSelect === 'none' || isCancelled;
253-
};
254-
expect(await refusesSelection()).toBe(false);
242+
// The actions' row, the group: its labels are never selected by a press
243+
// that slides across them, whatever the pointer.
244+
expect(await userSelect(del.locator('..'))).toBe('none');
245+
// The title and the message are outside the group: selectable.
246+
expect(await userSelect(dialog.getByRole('heading'))).not.toBe('none');
247+
const message = dialog.getByText('This action cannot be undone', {
248+
exact: false,
249+
});
250+
expect(await userSelect(message)).not.toBe('none');
251+
// A held finger on the actions changes nothing there.
255252
await driver.play(slide(centers.del, {x: centers.del.x, y: bottom + 60}), {
256253
onEvent: async (step, index) => {
257254
if (index !== 0) {
258255
return;
259256
}
260257
expect(step.type).toBe('touchStart');
261-
expect(await refusesSelection()).toBe(true);
258+
expect(await userSelect(message)).not.toBe('none');
262259
},
263260
});
264261
await expect(dialog).toBeVisible();
265-
expect(await refusesSelection()).toBe(false);
266262
});
267263

268264
test("no pan can take the group's press: the actions allow only pinch-zoom, and the rest of the alert keeps its pan", async ({
@@ -360,9 +356,8 @@ test.describe('with a mouse', () => {
360356
test('the dialog keeps its base styles: its text stays selectable', async ({
361357
page,
362358
}) => {
363-
// A held finger's suppressed selection (`spec:AST-094` FR41) is a
364-
// finger's or a pen's, never a mouse's: with a mouse the dialog keeps what
365-
// it had before.
359+
// Only the actions' row, the group, takes no text selection: with a
360+
// mouse the dialog's title and message stay selectable.
366361
await openStory(page, storybook(), 'core-alertdialog--delete');
367362
// A fine pointer in this context, before anything is checked.
368363
expect(

0 commit comments

Comments
 (0)