{children}
diff --git a/ui/src/components/PdRequirements.tsx b/ui/src/components/PdRequirements.tsx
index a3f18b7..319428c 100644
--- a/ui/src/components/PdRequirements.tsx
+++ b/ui/src/components/PdRequirements.tsx
@@ -83,23 +83,27 @@ export function PdRequirements({ env }: { env?: PyEnv | undefined }) {
{
- void doExport()
+ if (!busy) void doExport()
}}
data-action="export-requirements"
- className="rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40"
+ className="rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40 aria-disabled:opacity-40"
>
{t('requirements.export')}
{
- void doRead()
+ if (!busy) void doRead()
}}
data-action="import-requirements"
- className="rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40"
+ className="rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40 aria-disabled:opacity-40"
>
{t('requirements.import')}
diff --git a/ui/src/components/PdSidebar.tsx b/ui/src/components/PdSidebar.tsx
index 627cfbd..b87a849 100644
--- a/ui/src/components/PdSidebar.tsx
+++ b/ui/src/components/PdSidebar.tsx
@@ -60,8 +60,11 @@ export function PdSidebar() {
>
{t(`nav.${key}`)}
+ {/* A real space, not only a margin: inline spans are joined without one, and
+ the tab's accessible name read "Updates(5)". */}
+ {key === 'updates' && updatesCount > 0 ? ' ' : null}
{key === 'updates' && updatesCount > 0 ? (
-
+
{`(${String(updatesCount)})`}
) : null}
diff --git a/ui/src/components/PdUninstallDialog.test.tsx b/ui/src/components/PdUninstallDialog.test.tsx
index 248856b..b9af7e7 100644
--- a/ui/src/components/PdUninstallDialog.test.tsx
+++ b/ui/src/components/PdUninstallDialog.test.tsx
@@ -50,9 +50,8 @@ describe('PdUninstallDialog', () => {
// about follows, and the body is its description.
setup(BREAKING)
- expect(dialog()).toHaveAccessibleName(/^This removal breaks other packages.*numpy/)
+ expect(dialog()).toHaveAccessibleName('This removal breaks other packages: numpy')
expect(dialog()).toHaveAccessibleDescription(/pandas 2\.1\.4 requires numpy/)
- expect(dialog()).not.toHaveAttribute('aria-label')
})
it('focuses Cancel, and renders it first', () => {
diff --git a/ui/src/destructive.test.ts b/ui/src/destructive.test.ts
index b806e4e..52985b0 100644
--- a/ui/src/destructive.test.ts
+++ b/ui/src/destructive.test.ts
@@ -82,6 +82,23 @@ describe('destructive controls', () => {
expect(forced).not.toMatch(/button\[data-action=/)
})
+ it('is drawn outside every cascade layer, where a utility cannot undo it', () => {
+ // **The rule existed for a year and drew nothing.** It sat inside `@layer base`, and every
+ // button also carries Tailwind's `border` utility, which lives in a later layer — and a later
+ // layer wins whatever the selectors say. So `border: 2px` lost to `border-width: 1px`, and in
+ // high contrast a destructive button was drawn exactly like the Cancel beside it: for the five
+ // actions the old list named, as well as the five it had missed. Seen by emulating
+ // forced-colors in the installed build and looking; nothing here renders a stylesheet.
+ //
+ // An unlayered rule beats every layered one. Depth 1 is "inside the media query and nothing
+ // else".
+ const at = styles.lastIndexOf('button[data-destructive]')
+ const before = styles.slice(0, at).replace(/\/\*[\s\S]*?\*\//g, '')
+ const depth = before.split('{').length - before.split('}').length
+ expect(depth).toBe(1)
+ expect(styles.slice(styles.lastIndexOf('@media', at), at)).toContain('forced-colors: active')
+ })
+
it('outlines the sidebar tab that is showing', () => {
// The tab carries `aria-current="page"`; the rule matched `'true'`, so in high contrast the
// active tab looked like every other.
diff --git a/ui/src/screens/PdEnvironments.tsx b/ui/src/screens/PdEnvironments.tsx
index 3c5e81d..b81e152 100644
--- a/ui/src/screens/PdEnvironments.tsx
+++ b/ui/src/screens/PdEnvironments.tsx
@@ -95,10 +95,13 @@ function Row({ row }: { row: EnvRow }) {
{
- select(row.interpreter)
+ if (!isSelected) select(row.interpreter)
}}
- disabled={isSelected}
- className="rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40"
+ // Busy is `aria-disabled`, not `disabled`: a browser takes focus from a control that
+ // becomes disabled, so one that disables itself when pressed drops focus to
+ // (UI-SPEC §8).
+ aria-disabled={isSelected}
+ className="rounded-pd border border-border px-3 py-1 text-data aria-disabled:opacity-40"
>
{t('actions.use')}
@@ -212,10 +215,10 @@ export function PdEnvironments() {
{
- void scan()
+ if (!scanning) void scan()
}}
- disabled={scanning}
- className="rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40"
+ aria-disabled={scanning}
+ className="rounded-pd border border-border px-3 py-1 text-data aria-disabled:opacity-40"
>
{t('actions.rescan')}
diff --git a/ui/src/screens/PdHealth.tsx b/ui/src/screens/PdHealth.tsx
index 7260770..799a510 100644
--- a/ui/src/screens/PdHealth.tsx
+++ b/ui/src/screens/PdHealth.tsx
@@ -134,10 +134,13 @@ export function PdHealth() {
{
- if (env !== undefined) void run(env, row.envHash)
+ if (env !== undefined && !running) void run(env, row.envHash)
}}
>
{running ? t('health.running') : t('health.run')}
diff --git a/ui/src/screens/PdPlanPanel.tsx b/ui/src/screens/PdPlanPanel.tsx
index c704bc1..6448f7c 100644
--- a/ui/src/screens/PdPlanPanel.tsx
+++ b/ui/src/screens/PdPlanPanel.tsx
@@ -229,11 +229,14 @@ export function PdPlanPanel({ onFinished }: PdPlanPanelProps) {
{
- void cancel()
+ if (!cancelling) void cancel()
}}
- disabled={cancelling}
+ // Busy is `aria-disabled`, not `disabled`: a browser takes focus from a control that
+ // becomes disabled, so one that disables itself when pressed drops focus to
+ // (UI-SPEC §8).
+ aria-disabled={cancelling}
data-destructive
- className="rounded-pd border border-danger px-3 py-1 text-data text-danger disabled:opacity-40"
+ className="rounded-pd border border-danger px-3 py-1 text-data text-danger aria-disabled:opacity-40"
>
{cancelling ? t('plan.stopping') : t('plan.stop')}
diff --git a/ui/src/screens/PdSearch.test.tsx b/ui/src/screens/PdSearch.test.tsx
index 4149b2e..1c35b02 100644
--- a/ui/src/screens/PdSearch.test.tsx
+++ b/ui/src/screens/PdSearch.test.tsx
@@ -1,4 +1,4 @@
-import { render, screen, within } from '@testing-library/react'
+import { fireEvent, render, screen, within } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { Hit } from '@/ipc'
@@ -59,6 +59,51 @@ describe('what Search says without being looked at', () => {
expect(within(screen.getByRole('status')).getByText(/nothing matches/)).toHaveClass('sr-only')
})
+ it('keeps a button focusable after it has been pressed', () => {
+ // **Found in the installed build, not here.** *Add* and *Download the index* disabled
+ // themselves the moment they were pressed, and a browser takes focus away from a control that
+ // becomes `disabled` — so pressing either dropped focus to . jsdom does not do that,
+ // which is why no test could see it; what a test can hold is the contract that avoids it:
+ // busy is `aria-disabled`, which greys the button and keeps it where focus is.
+ useIndexStore.setState({
+ query: 'num',
+ hits: HITS,
+ queue: [{ name: 'numpy', version: '' }],
+ unavailable: 'missing',
+ refreshing: true,
+ })
+ render( )
+
+ const queued = screen.getByRole('button', { name: 'Queued' })
+ expect(queued).toHaveAttribute('aria-disabled', 'true')
+ expect(queued).not.toBeDisabled()
+
+ const refresh = screen.getByRole('button', { name: 'Downloading…' })
+ expect(refresh).toHaveAttribute('aria-disabled', 'true')
+ expect(refresh).not.toBeDisabled()
+ })
+
+ it('does nothing when a busy button is pressed again', () => {
+ const refreshIndex = vi.fn()
+ const enqueue = vi.fn()
+ useIndexStore.setState({
+ query: 'num',
+ hits: HITS,
+ queue: [{ name: 'numpy', version: '' }],
+ unavailable: 'missing',
+ refreshing: true,
+ refreshIndex,
+ enqueue,
+ })
+ render( )
+
+ fireEvent.click(screen.getByRole('button', { name: 'Queued' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Downloading…' }))
+
+ expect(enqueue).not.toHaveBeenCalled()
+ expect(refreshIndex).not.toHaveBeenCalled()
+ })
+
it('marks the result whose details are showing', () => {
// Selection was a background colour and nothing else, which forced-colors erases.
useIndexStore.setState({ query: 'num', hits: HITS, selected: 'numpydoc' })
diff --git a/ui/src/screens/PdSearch.tsx b/ui/src/screens/PdSearch.tsx
index 1f85a65..a504cb4 100644
--- a/ui/src/screens/PdSearch.tsx
+++ b/ui/src/screens/PdSearch.tsx
@@ -129,10 +129,13 @@ export function PdSearch() {
{
- void refreshIndex()
+ if (!refreshing) void refreshIndex()
}}
- disabled={refreshing}
- className="mt-2 rounded-pd border border-border px-3 py-1 text-data disabled:opacity-40"
+ // Busy is `aria-disabled`, not `disabled`: a browser takes focus from a control that
+ // becomes disabled, so one that disables itself when pressed drops focus to
+ // (UI-SPEC §8).
+ aria-disabled={refreshing}
+ className="mt-2 rounded-pd border border-border px-3 py-1 text-data aria-disabled:opacity-40"
>
{refreshing ? t('search.refreshing') : t('search.refreshIndex')}
@@ -200,10 +203,10 @@ export function PdSearch() {
{
- enqueue(hit.name)
+ if (!queued) enqueue(hit.name)
}}
- disabled={queued}
- className="shrink-0 rounded-pd border border-border px-2 py-0.5 text-data disabled:opacity-40"
+ aria-disabled={queued}
+ className="shrink-0 rounded-pd border border-border px-2 py-0.5 text-data aria-disabled:opacity-40"
>
{queued ? t('search.queued') : t('search.add')}
diff --git a/ui/src/screens/PdSecurity.test.tsx b/ui/src/screens/PdSecurity.test.tsx
index a23294d..c669bfb 100644
--- a/ui/src/screens/PdSecurity.test.tsx
+++ b/ui/src/screens/PdSecurity.test.tsx
@@ -75,7 +75,11 @@ describe('PdSecurity', () => {
expect(screen.queryByText(/No audit has run/)).toBeNull()
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument()
- expect(screen.getByRole('button', { name: 'Run audit' })).toBeDisabled()
+ // Busy, and still focusable: a control that goes `disabled` under the user's finger drops
+ // focus to in a real browser (see PdSearch.test.tsx).
+ const run = screen.getByRole('button', { name: 'Run audit' })
+ expect(run).toHaveAttribute('aria-disabled', 'true')
+ expect(run).not.toBeDisabled()
})
it('shows the report only for the environment it belongs to', () => {
diff --git a/ui/src/screens/PdSecurity.tsx b/ui/src/screens/PdSecurity.tsx
index 7acd070..41f397c 100644
--- a/ui/src/screens/PdSecurity.tsx
+++ b/ui/src/screens/PdSecurity.tsx
@@ -74,11 +74,14 @@ export function PdSecurity() {
{
- if (env !== undefined && row !== undefined) void run(env, row.envHash)
+ if (env !== undefined && row !== undefined && !running) void run(env, row.envHash)
}}
- className="rounded-pd bg-surface-2 px-3 py-1.5 text-accent disabled:opacity-40"
+ className="rounded-pd bg-surface-2 px-3 py-1.5 text-accent disabled:opacity-40 aria-disabled:opacity-40"
>
{t('security.run')}
diff --git a/ui/src/styles.css b/ui/src/styles.css
index fd39c2a..75d64d4 100644
--- a/ui/src/styles.css
+++ b/ui/src/styles.css
@@ -167,14 +167,28 @@
outline: 1px solid Highlight;
}
- /* Destructive controls, which are otherwise indistinguishable once their tint is dropped.
- *
- * One attribute, not a list of `data-action` values. The list was five names long and missed
- * Remove, Allow, Clear, the Force-latest confirm and a forced plan's Confirm for as long as it
- * existed (U45) — a list of names beside a list of buttons is two lists. `destructive.test.ts`
- * holds the other half: every button drawn in the danger colour carries the attribute. */
- button[data-destructive] {
- border: 2px solid CanvasText;
- }
+ }
+}
+
+/* Destructive controls, which are otherwise indistinguishable once their tint is dropped.
+ *
+ * **Outside every `@layer`, and that is the whole fix.** This rule lived in the base layer above
+ * for as long as it existed, and drew nothing: every button also carries Tailwind's `border`
+ * utility, the utilities layer comes later, and a later layer wins whatever the selectors say — so
+ * `border: 2px` lost to `border-width: 1px`, and in high contrast *Remove anyway* was drawn exactly
+ * like the Cancel beside it. Found by emulating forced-colors in the installed build and looking.
+ * An unlayered rule beats every layered one.
+ *
+ * **A double line, not a thicker one.** Told apart from 1px, 2px is a difference nobody sees at a
+ * glance; a double border is a different shape, and it is not the focus ring, which is an outline
+ * in `Highlight`.
+ *
+ * One attribute, not a list of `data-action` values. The list was five names long and missed
+ * Remove, Allow, Clear, the Force-latest confirm and a forced plan's Confirm (U45) — a list of
+ * names beside a list of buttons is two lists. `destructive.test.ts` holds the other half: every
+ * button drawn in the danger colour carries the attribute, and this rule is in no layer. */
+@media (forced-colors: active) {
+ button[data-destructive] {
+ border: 3px double CanvasText;
}
}