diff --git a/e2e/connections.spec.ts b/e2e/connections.spec.ts index 6943f7e2..e1bf83e0 100644 --- a/e2e/connections.spec.ts +++ b/e2e/connections.spec.ts @@ -92,7 +92,10 @@ test('Home and End move between rows from a control inside a cell', async ({page const grid = page.getByRole('grid', {name: 'Connections'}); const focusedRow = grid.locator('[role=row]:focus'); const inCell = grid.locator(':is([role=rowheader], [role=gridcell]) :focus'); - await grid.locator('[data-key="c-0002"]').getByRole('gridcell').nth(1).click(); + const cell = grid.locator('[data-key="c-0002"]').getByRole('gridcell').nth(1); + await cell.click(); + await expect(grid.locator('[data-key="c-0002"]')).toHaveAttribute('aria-selected', 'true'); + await cell.locator('.rp-truncate').focus(); await expect(inCell).toHaveCount(1); await page.keyboard.press('End'); await expect(focusedRow).toHaveAttribute('aria-rowindex', '1001'); diff --git a/playwright.config.ts b/playwright.config.ts index ecb6a53c..79324cfb 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -22,6 +22,7 @@ export default defineConfig({ projects: [ {name: 'chromium', testIgnore: 'subpath.spec.ts', use: {...devices['Desktop Chrome']}}, {name: 'subpath', testMatch: 'subpath.spec.ts', use: {...devices['Desktop Chrome'], baseURL: 'http://127.0.0.1:4186'}}, + ...(process.env.DOONA_E2E_FIREFOX === '1' ? [{name: 'firefox', testMatch: 'connections.spec.ts', use: {...devices['Desktop Firefox']}}] : []), ...(webkit ? [ // Safari carries the installed iOS app: a smoke pass over navigation, drag and drop, dialogs and the keyboard. diff --git a/src/ui/Table.tsx b/src/ui/Table.tsx index 4bf11a30..a64b489a 100644 --- a/src/ui/Table.tsx +++ b/src/ui/Table.tsx @@ -340,16 +340,21 @@ export function DataTable({ data-row-detail={rowDetail || detail ? '' : undefined} style={{height: fitted}} // RAC (1.21) keeps Home/End inside the row while a cell or a control in one has focus, which is where a click on - // cut text leaves it. Focusing the row first sends them to the first and last rows instead, as the tree mode - // promises. The container passes no key handlers, so a tree renders its own div to catch the key first. + // cut text leaves it. Focus the row and re-dispatch there so the cell cannot handle the original event. + // The container passes no key handlers, so a tree renders its own div to catch the key first. render={ tree ? props => (
{ - if (event.key === 'Home' || event.key === 'End') - (event.target as HTMLElement).closest('[role="row"][data-key]')?.focus({preventScroll: true}); + if (event.key !== 'Home' && event.key !== 'End') return; + const row = (event.target as HTMLElement).closest('[role="row"][data-key]'); + if (!row || event.target === row) return; + event.preventDefault(); + event.stopPropagation(); + row.focus({preventScroll: true}); + row.dispatchEvent(new KeyboardEvent(event.nativeEvent.type, event.nativeEvent)); }} /> )