Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): make the result table scrollers focusable and named

Yudhi Armyndharis60689f17aa5f
diff --git a/dashboard/src/pages/NumberChecker.test.ts b/dashboard/src/pages/NumberChecker.test.ts
index 066bd6859..fc22acc3d 100644
--- a/dashboard/src/pages/NumberChecker.test.ts
+++ b/dashboard/src/pages/NumberChecker.test.ts
@@ -341,22 +341,32 @@ test('NumberChecker: the number field and the bulk list are typed left to right,
assert.equal(container.querySelector('.nc-textarea')?.getAttribute('dir'), 'ltr');
});
-test('NumberChecker: both result tables sit in a scroll container, so a narrow card does not clip them', async () => {
+// A scroller is not focusable by itself in every browser, and an unnamed one is not announced: Safari users on a keyboard
+// need the tab stop to scroll the columns that do not fit, and a screen reader needs to know what it is on.
+test('NumberChecker: both result tables sit in a named, focusable scroll container that a narrow card does not clip', async () => {
stubLookups(registered);
const { container } = renderComponent();
await rtl.screen.findByRole('option', { name: /Primary Session/ });
rtl.fireEvent.change(rtl.screen.getByPlaceholderText(/9876543210/), { target: { value: '919876543210' } });
rtl.fireEvent.click(rtl.screen.getByRole('button', { name: 'Check' }));
await rtl.screen.findByText('Registered', { selector: '.nc-status-badge' });
+ const wrapper = () => container.querySelector('.nc-history-table')?.parentElement;
assert.equal(container.querySelectorAll('.nc-history-table').length, 1);
- assert.equal(container.querySelector('.nc-history-table')?.parentElement?.className, 'nc-table-wrap');
+ assert.equal(wrapper()?.className, 'nc-table-wrap');
+ assert.equal(wrapper()?.getAttribute('tabindex'), '0');
+ assert.equal(wrapper()?.getAttribute('role'), 'region');
+ assert.equal(wrapper()?.getAttribute('aria-label'), 'Recent Checks');
+ assert.equal(rtl.screen.getByRole('region', { name: 'Recent Checks' }), wrapper());
rtl.fireEvent.click(rtl.screen.getByRole('tab', { name: /Bulk/i }));
rtl.fireEvent.change(rtl.screen.getByPlaceholderText(/9612345678/i), { target: { value: '911111111111' } });
startBatch();
await rtl.screen.findByText('+911111111111');
assert.equal(container.querySelectorAll('.nc-history-table').length, 1);
- assert.equal(container.querySelector('.nc-history-table')?.parentElement?.className, 'nc-table-wrap');
+ assert.equal(wrapper()?.className, 'nc-table-wrap');
+ assert.equal(wrapper()?.getAttribute('tabindex'), '0');
+ assert.equal(wrapper()?.getAttribute('role'), 'region');
+ assert.equal(wrapper()?.getAttribute('aria-label'), 'Bulk Number Checker');
});
test('NumberChecker: the Message Tester button reads as a plain link, because it passes no number along', async () => {
diff --git a/dashboard/src/pages/NumberChecker.tsx b/dashboard/src/pages/NumberChecker.tsx
index cb86bf845..93251a3a7 100644
--- a/dashboard/src/pages/NumberChecker.tsx
+++ b/dashboard/src/pages/NumberChecker.tsx
@@ -662,7 +662,7 @@ export function NumberChecker() {
</button>
</div>
- <div className="nc-table-wrap">
+ <div className="nc-table-wrap" tabIndex={0} role="region" aria-label={t('numberChecker.recent.title')}>
<table className="nc-history-table">
<thead>
<tr>
@@ -955,7 +955,7 @@ export function NumberChecker() {
</div>
</div>
- <div className="nc-table-wrap">
+ <div className="nc-table-wrap" tabIndex={0} role="region" aria-label={t('numberChecker.bulk.title')}>
<table className="nc-history-table">
<thead>
<tr>