diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.nestedFocus.test.tsx b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.nestedFocus.test.tsx
index b7d742555b95..c00946403a33 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.nestedFocus.test.tsx
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.nestedFocus.test.tsx
@@ -122,7 +122,10 @@ test('keyboard, four levels: Tab enters and leaves every nested grid (headers, c
'0 gridcell ',
'0 gridcell Q2',
]);
- expect(await walkDeep(2)).toEqual(['0 combobox Page Size:', '0 li 1']);
+ expect(await walkDeep(2)).toEqual([
+ '0 combobox Page Size:',
+ '0 button Page 1',
+ ]);
parentCell(container, 'row-1', 'queue').focus();
const back = await walkDeep(24, true);
expect(back).toEqual(
diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.test.tsx b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.test.tsx
index 0ffa797fd8d6..daec200473cb 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.test.tsx
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTableChart.test.tsx
@@ -867,8 +867,7 @@ test('Enter on a page number of the new pager sends the page change once and clo
);
await openFirst();
await screen.findAllByText('2 Steps');
- const page = screen.getByTitle('2');
- page.focus();
+ screen.getByLabelText('Page 2').focus();
await userEvent.keyboard('{Enter}');
await waitFor(() =>
expect(onMask).toHaveBeenCalledWith({ ownState: { currentPage: 1 } }),
@@ -880,5 +879,5 @@ test('Enter on a page number of the new pager sends the page change once and clo
expect(
container.querySelector('.ant-pagination-item-active'),
).toHaveAttribute('title', '2');
- expect(document.activeElement).toBe(screen.getByTitle('2'));
+ expect(document.activeElement).toBe(screen.getByLabelText('Page 2'));
});
diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.test.tsx b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.test.tsx
index 0409c0bca803..a0fbeeb17643 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.test.tsx
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.test.tsx
@@ -101,29 +101,32 @@ test('Tab order: select, then page numbers, the jump and Next; disabled Previous
}
expect(order).toEqual([
'Page Size:',
- '1',
- '2',
- '3',
+ 'Page 1',
+ 'Page 2',
+ 'Page 3',
'Next 3 Pages',
- '26',
+ 'Page 26',
'Next Page',
]);
- expect(screen.getByTitle('Previous Page')).toHaveAttribute(
+ expect(screen.getByLabelText('Previous Page')).toHaveAttribute(
'aria-disabled',
'true',
);
- expect(screen.getByTitle('Previous Page')).not.toHaveAttribute('tabindex');
+ expect(screen.getByLabelText('Previous Page')).toHaveAttribute(
+ 'tabindex',
+ '-1',
+ );
});
test('Enter on a page number, the jump, Next and Previous changes the page once each', async () => {
const { onPageChange } = renderPager({ currentPage: 1 });
- screen.getByTitle('3').focus();
+ screen.getByLabelText('Page 3').focus();
await userEvent.keyboard('{Enter}');
- screen.getByTitle('Next Page').focus();
+ screen.getByLabelText('Next Page').focus();
await userEvent.keyboard('{Enter}');
- screen.getByTitle('Previous Page').focus();
+ screen.getByLabelText('Previous Page').focus();
await userEvent.keyboard('{Enter}');
- screen.getByTitle('Next 3 Pages').focus();
+ screen.getByLabelText('Next 3 Pages').focus();
await userEvent.keyboard('{Enter}');
expect(onPageChange.mock.calls).toEqual([[2], [2], [0], [4]]);
});
@@ -137,11 +140,11 @@ test('Space on a page number does nothing (platform pager: Enter only)', async (
test('the last page is reached through its number; Next is disabled there', async () => {
const { onPageChange } = renderPager({ currentPage: 25 });
- expect(screen.getByTitle('Next Page')).toHaveAttribute(
+ expect(screen.getByLabelText('Next Page')).toHaveAttribute(
'aria-disabled',
'true',
);
- screen.getByTitle('1').focus();
+ screen.getByLabelText('Page 1').focus();
await userEvent.keyboard('{Enter}');
expect(onPageChange).toHaveBeenCalledWith(0);
});
@@ -181,35 +184,34 @@ function Controlled({ total }: { total: number }) {
test('RB8: after a keyboard page change focus stays on the page control used', async () => {
render();
- const two = screen.getByTitle('2');
- two.focus();
+ screen.getByLabelText('Page 2').focus();
await userEvent.keyboard('{Enter}');
await waitFor(() =>
expect(screen.getByTitle('2')).toHaveClass('ant-pagination-item-active'),
);
await act(() => new Promise(resolve => setTimeout(resolve, 30)));
- expect(document.activeElement).toBe(screen.getByTitle('2'));
+ expect(document.activeElement).toBe(screen.getByLabelText('Page 2'));
});
test('RB8: when the control used goes away (Next on the last page turns disabled), the new current page takes focus', async () => {
render();
- screen.getByTitle('Next Page').focus();
+ screen.getByLabelText('Next Page').focus();
await userEvent.keyboard('{Enter}');
await waitFor(() =>
expect(screen.getByTitle('2')).toHaveClass('ant-pagination-item-active'),
);
- screen.getByTitle('Next Page').focus();
+ screen.getByLabelText('Next Page').focus();
await userEvent.keyboard('{Enter}');
await waitFor(() =>
expect(screen.getByTitle('3')).toHaveClass('ant-pagination-item-active'),
);
// jsdom keeps focus on a control that lost its tab stop; a browser drops it
// to the page, which blur() stands in for.
- const next = screen.getByTitle('Next Page');
+ const next = screen.getByLabelText('Next Page');
expect(document.activeElement).toBe(next);
next.setAttribute('tabindex', '0');
act(() => next.blur());
await waitFor(() =>
- expect(document.activeElement).toBe(screen.getByTitle('3')),
+ expect(document.activeElement).toBe(screen.getByLabelText('Page 3')),
);
});
diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.tsx b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.tsx
index 1e479f2c1b4e..2209c1974d0b 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.tsx
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/TreeTable/TreeTablePager.tsx
@@ -33,7 +33,7 @@ export interface TreeTablePagerProps {
onPageSizeChange: (pageSize: number) => void;
}
-const ACTIVE_PAGE = '.ant-pagination-item-active';
+const ACTIVE_PAGE = '.ant-pagination-item-active a';
const formatInteger = getNumberFormatter(NumberFormats.INTEGER);
/**