|
12 | 12 | * off both; only the actions are tracked, so a touch that lands on the |
13 | 13 | * message runs nothing; a tap and a mouse click run their action once; a |
14 | 14 | * 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; |
17 | 18 | * a storyboard of the slide from Delete to Cancel. |
18 | 19 | * @position Touch lane of AlertDialog, beside the accessibility bindings in |
19 | 20 | * 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 ({ |
226 | 227 | expect((await readLog(page)).clicks).toEqual([]); |
227 | 228 | }); |
228 | 229 |
|
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 ({ |
230 | 231 | page, |
231 | 232 | }) => { |
232 | 233 | 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 => { |
241 | 236 | const style = getComputedStyle(element); |
242 | 237 | return ( |
243 | 238 | style.getPropertyValue('user-select') || |
244 | 239 | style.getPropertyValue('-webkit-user-select') |
245 | 240 | ); |
246 | 241 | }); |
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. |
255 | 252 | await driver.play(slide(centers.del, {x: centers.del.x, y: bottom + 60}), { |
256 | 253 | onEvent: async (step, index) => { |
257 | 254 | if (index !== 0) { |
258 | 255 | return; |
259 | 256 | } |
260 | 257 | expect(step.type).toBe('touchStart'); |
261 | | - expect(await refusesSelection()).toBe(true); |
| 258 | + expect(await userSelect(message)).not.toBe('none'); |
262 | 259 | }, |
263 | 260 | }); |
264 | 261 | await expect(dialog).toBeVisible(); |
265 | | - expect(await refusesSelection()).toBe(false); |
266 | 262 | }); |
267 | 263 |
|
268 | 264 | 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', () => { |
360 | 356 | test('the dialog keeps its base styles: its text stays selectable', async ({ |
361 | 357 | page, |
362 | 358 | }) => { |
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. |
366 | 361 | await openStory(page, storybook(), 'core-alertdialog--delete'); |
367 | 362 | // A fine pointer in this context, before anything is checked. |
368 | 363 | expect( |
|
0 commit comments