diff --git a/website/src/apps/ops-mission-control/HandoverPanel.coverage.test.tsx b/website/src/apps/ops-mission-control/HandoverPanel.coverage.test.tsx
index a6208647a3bf..b3a1b0af3659 100644
--- a/website/src/apps/ops-mission-control/HandoverPanel.coverage.test.tsx
+++ b/website/src/apps/ops-mission-control/HandoverPanel.coverage.test.tsx
@@ -135,4 +135,30 @@ describe('HandoverPanel error and refresh', () => {
})
await waitFor(() => expect(vi.mocked(opsApi.handover).mock.calls.length).toBeGreaterThan(before))
})
+
+ it('keeps keyboard focus on Refresh while it runs, and ignores a second press', async () => {
+ // A native `disabled` takes the focused button out of the tab order, so a
+ // keyboard press dropped focus to the page for the whole refresh.
+ renderWithProviders()
+ const label = await screen.findByText(i18nT('apps.opsMissionControl.handoverPanel.refresh'))
+ const button = label.closest('button') as HTMLButtonElement
+ let release: (v: unknown) => void = () => {}
+ vi.mocked(opsApi.handover).mockReturnValue(new Promise(resolve => { release = resolve }) as never)
+ const calls = vi.mocked(opsApi.handover).mock.calls.length
+
+ button.focus()
+ fireEvent.click(button)
+ await screen.findByText(i18nT('apps.opsMissionControl.handoverPanel.refreshing'))
+ expect(button).toHaveAttribute('aria-disabled', 'true')
+ expect(button).not.toBeDisabled()
+ expect(button).toHaveFocus()
+
+ fireEvent.click(button)
+ expect(vi.mocked(opsApi.handover).mock.calls.length).toBe(calls + 1)
+
+ await act(async () => { release(digest()) })
+ await screen.findByText(i18nT('apps.opsMissionControl.handoverPanel.refresh'))
+ expect(button).not.toHaveAttribute('aria-disabled')
+ expect(button).toHaveFocus()
+ })
})
diff --git a/website/src/apps/ops-mission-control/HandoverPanel.tsx b/website/src/apps/ops-mission-control/HandoverPanel.tsx
index afc38f9effe8..197399255ea0 100644
--- a/website/src/apps/ops-mission-control/HandoverPanel.tsx
+++ b/website/src/apps/ops-mission-control/HandoverPanel.tsx
@@ -172,7 +172,13 @@ export default function HandoverPanel() {
{/* The one line someone gets if they read nothing else. */}
{digest?.headline}
-
query.refetch()}>
+ {/* `aria-disabled` plus the guard, NOT `disabled`, which leaves the tab
+ order and drops a keyboard user's focus to the page while it runs. */}
+ { if (!query.isFetching) void query.refetch() }}
+ >
{' '}
{query.isFetching
? i18nT('apps.opsMissionControl.handoverPanel.refreshing')
diff --git a/website/src/apps/ops-mission-control/OpsSignalsPanelCoverage.test.tsx b/website/src/apps/ops-mission-control/OpsSignalsPanelCoverage.test.tsx
index ef6702671682..92c86bf77793 100644
--- a/website/src/apps/ops-mission-control/OpsSignalsPanelCoverage.test.tsx
+++ b/website/src/apps/ops-mission-control/OpsSignalsPanelCoverage.test.tsx
@@ -402,7 +402,7 @@ describe('SignalsPanel', () => {
fireEvent.click(button)
const polling = await screen.findByRole('button', { name: /Polling…/ })
- expect(polling).toBeDisabled()
+ expect(polling).toHaveAttribute('aria-disabled', 'true')
await act(async () => {
reject(new Error('the /signals route refused the poll'))
@@ -414,7 +414,37 @@ describe('SignalsPanel', () => {
timeout: 5_000,
}),
).toBeInTheDocument()
- expect(screen.getByRole('button', { name: /Poll now/ })).toBeEnabled()
+ expect(screen.getByRole('button', { name: /Poll now/ })).not.toHaveAttribute('aria-disabled')
+ })
+
+ it('keeps keyboard focus on Poll now while polling, and ignores a second press', async () => {
+ // A native `disabled` takes the focused button out of the tab order, so a
+ // keyboard press dropped focus to the page for the whole poll.
+ await renderPanel()
+ let resolve: (v: SignalsResult) => void = () => {}
+ vi.mocked(opsApi.signals).mockReturnValue(
+ new Promise(res => {
+ resolve = res
+ }),
+ )
+ const calls = vi.mocked(opsApi.signals).mock.calls.length
+
+ const button = screen.getByRole('button', { name: /Poll now/ })
+ button.focus()
+ fireEvent.click(button)
+ await screen.findByRole('button', { name: /Polling…/ })
+ expect(button).not.toBeDisabled()
+ expect(button).toHaveFocus()
+
+ fireEvent.click(button)
+ expect(vi.mocked(opsApi.signals).mock.calls.length).toBe(calls + 1)
+
+ await act(async () => {
+ resolve(mkSignalsResult())
+ await Promise.resolve()
+ })
+ await screen.findByRole('button', { name: /Poll now/ })
+ expect(button).toHaveFocus()
})
it('reports an exact ledger match and a cleared fast path on the claim receipt', async () => {
diff --git a/website/src/apps/ops-mission-control/SignalsPanel.tsx b/website/src/apps/ops-mission-control/SignalsPanel.tsx
index 70c6e9172efb..d0662fb0d79f 100644
--- a/website/src/apps/ops-mission-control/SignalsPanel.tsx
+++ b/website/src/apps/ops-mission-control/SignalsPanel.tsx
@@ -333,9 +333,12 @@ export default function SignalsPanel() {
)}
+ {/* `aria-disabled` plus the guard, NOT `disabled`, which leaves the tab
+ order and drops a keyboard user's focus to the page while it polls. */}
signalsQuery.refetch()}
+ aria-disabled={signalsQuery.isFetching || undefined}
+ className="aria-disabled:opacity-30 aria-disabled:cursor-default"
+ onClick={() => { if (!signalsQuery.isFetching) void signalsQuery.refetch() }}
title={i18nT('apps.opsMissionControl.signalsPanel.poll_every_configured_source_now_read_only')}
>
{' '}