|
16 | 16 | * (its served operations leave `get` out, `servesRecordRead`). The host hands |
17 | 17 | * that answer down as `rowOpensRecord`, and each card face reads it: the |
18 | 18 | * gallery card, the board card and the phone card draw no pointer and no hover |
19 | | - * lift, and a tap on one opens nothing. Card actions stay (the phone card's |
20 | | - * "⋮"), and a board card the reader may drag keeps its grab cursor. |
| 19 | + * lift, and a tap on one opens nothing. A board card that cannot be dragged |
| 20 | + * either is no control at all: no `button` role, no tab stop, no title hover. |
| 21 | + * Card actions stay (the phone card's "⋮"), and a board card the reader may |
| 22 | + * drag keeps its drag semantics. |
21 | 23 | * |
22 | 24 | * Driven through the real `ObjectView`, `ListView`, gallery, board and grid, |
23 | 25 | * and the real `MePermissionsProvider`: one differential per face, the same |
@@ -273,6 +275,16 @@ async function phoneCard(title: string): Promise<HTMLElement> { |
273 | 275 | return card as HTMLElement; |
274 | 276 | } |
275 | 277 |
|
| 278 | +/** Whether the board card's wrapper is a control: a `button` a Tab reaches. */ |
| 279 | +function isBoardControl(control: HTMLElement): boolean { |
| 280 | + return control.getAttribute('role') === 'button' && control.getAttribute('tabindex') === '0'; |
| 281 | +} |
| 282 | + |
| 283 | +/** Whether the board card's face drives its title's hover colour (`group` → `group-hover:text-primary`). */ |
| 284 | +function hasTitleHover(face: HTMLElement): boolean { |
| 285 | + return /(^|\s)group(\s|$)/.test(face.className) && face.querySelector('[class*="group-hover:"]') !== null; |
| 286 | +} |
| 287 | + |
276 | 288 | /** Whether `el` wears a clickable face: the pointer, or a hover lift / wash. */ |
277 | 289 | function looksClickable(el: HTMLElement): boolean { |
278 | 290 | return /(^|\s)(cursor-pointer|hover:shadow-lg|hover:bg-accent\/50)(\s|$)/.test(el.className); |
@@ -334,17 +346,41 @@ describe('objectstack#33548 — board cards on a list whose rows open nothing', |
334 | 346 | expect(openSpy).not.toHaveBeenCalled(); |
335 | 347 | }); |
336 | 348 |
|
337 | | - it('authored `none`, a card the reader may drag: the grab cursor stays, and no pointer is added', async () => { |
| 349 | + it('authored `none`, a card the reader may not drag: the card is no control — no button role, no tab stop, no title hover', async () => { |
| 350 | + await mountList({ view: { type: 'kanban', navigation: { mode: 'none' } }, allowEdit: false }); |
| 351 | + const { control, face } = await boardCard('c1'); |
| 352 | + expect(isBoardControl(control)).toBe(false); |
| 353 | + expect(hasTitleHover(face)).toBe(false); |
| 354 | + }); |
| 355 | + |
| 356 | + it('a list-only object, a card the reader may not drag: the card is no control either', async () => { |
| 357 | + await mountList({ view: { type: 'kanban' }, apiOperations: LIST_ONLY_OPERATIONS, allowEdit: false }); |
| 358 | + const { control, face } = await boardCard('c1'); |
| 359 | + expect(isBoardControl(control)).toBe(false); |
| 360 | + expect(hasTitleHover(face)).toBe(false); |
| 361 | + }); |
| 362 | + |
| 363 | + it('authored `none`, a card the reader may drag: it keeps its drag semantics — the grab cursor, the button role and the tab stop — and gains no pointer', async () => { |
338 | 364 | await mountList({ view: { type: 'kanban', navigation: { mode: 'none' } } }); |
339 | | - const { face } = await boardCard('c1'); |
| 365 | + const { control, face } = await boardCard('c1'); |
340 | 366 | expect(face.className).toMatch(/(^|\s)cursor-grab(\s|$)/); |
341 | 367 | expect(face.className).not.toMatch(/(^|\s)cursor-pointer(\s|$)/); |
| 368 | + expect(isBoardControl(control)).toBe(true); |
342 | 369 | }); |
343 | 370 |
|
344 | | - it('CONTROL — the default drawer, a card the reader may not drag: the card wears the pointer and a tap opens the drawer', async () => { |
| 371 | + it('CONTROL — the default drawer, a card the reader may not drag: a control with the pointer and title hover; Enter opens the drawer', async () => { |
345 | 372 | await mountList({ view: { type: 'kanban' }, allowEdit: false }); |
346 | 373 | const { control, face } = await boardCard('c1'); |
347 | 374 | expect(face.className).toMatch(/(^|\s)cursor-pointer(\s|$)/); |
| 375 | + expect(isBoardControl(control)).toBe(true); |
| 376 | + expect(hasTitleHover(face)).toBe(true); |
| 377 | + fireEvent.keyDown(control, { key: 'Enter' }); |
| 378 | + await waitFor(() => expect(location()).toContain('recordId=c1')); |
| 379 | + }); |
| 380 | + |
| 381 | + it('CONTROL — the default drawer: a tap on the card opens the drawer', async () => { |
| 382 | + await mountList({ view: { type: 'kanban' }, allowEdit: false }); |
| 383 | + const { control } = await boardCard('c1'); |
348 | 384 | fireEvent.click(control); |
349 | 385 | await waitFor(() => expect(location()).toContain('recordId=c1')); |
350 | 386 | }); |
|
0 commit comments