Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): name the impact details in the confirm accessible description (R1-L2)

Diego Zacarias3bf3c451e7c5
diff --git a/control-ui/components/ConfirmDialog/index.tsx b/control-ui/components/ConfirmDialog/index.tsx
index 656a9f2d1..45c9f461c 100644
--- a/control-ui/components/ConfirmDialog/index.tsx
+++ b/control-ui/components/ConfirmDialog/index.tsx
@@ -6,6 +6,7 @@ import type { ConfirmDialogOptions, ConfirmDialogProps, ConfirmDialogRequest } f
function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
const titleId = useId()
const messageId = useId()
+ const detailsId = useId()
const cancelButtonRef = useRef<HTMLButtonElement | null>(null)
useEffect(() => {
@@ -50,7 +51,7 @@ function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
role="alertdialog"
aria-modal="true"
aria-labelledby={titleId}
- aria-describedby={messageId}
+ aria-describedby={details ? `${messageId} ${detailsId}` : messageId}
onMouseDown={event => event.stopPropagation()}
>
<div className="cu-modal-panel__head">
@@ -61,7 +62,11 @@ function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
<p id={messageId} className="cu-modal-copy">
{message}
</p>
- {details ? <div className="cu-modal-copy cu-modal-copy--details">{details}</div> : null}
+ {details ? (
+ <div id={detailsId} className="cu-modal-copy cu-modal-copy--details">
+ {details}
+ </div>
+ ) : null}
<div className="cu-modal-panel__foot">
<button
ref={cancelButtonRef}
diff --git a/control-ui/components/__tests__/ConfirmDialog.test.tsx b/control-ui/components/__tests__/ConfirmDialog.test.tsx
new file mode 100644
index 000000000..6add469e5
--- /dev/null
+++ b/control-ui/components/__tests__/ConfirmDialog.test.tsx
@@ -0,0 +1,49 @@
+import { useEffect } from 'react'
+import { afterEach, describe, expect, it } from 'vitest'
+import { cleanup, render, screen } from '@testing-library/react'
+import { useConfirmDialog } from '../ConfirmDialog'
+import type { ConfirmDialogOptions } from '../ConfirmDialog/types'
+
+afterEach(cleanup)
+
+// Drives the real hook: opens a confirm with the given options on mount and
+// renders the dialog element it returns, so the test exercises the same
+// aria wiring the surfaces use.
+function ConfirmHarness({ options }: { options: ConfirmDialogOptions }) {
+ const { confirm, confirmDialog } = useConfirmDialog()
+ useEffect(() => {
+ void confirm(options)
+ }, [confirm, options])
+ return confirmDialog
+}
+
+describe('ConfirmDialog accessibility', () => {
+ it('names the details block in the alertdialog accessible description', () => {
+ render(
+ <ConfirmHarness
+ options={{
+ title: 'Model still in use',
+ message: 'Disabling this model would strand its references.',
+ details: <span>Impacted: team-a/reader, team-b/writer</span>,
+ confirmLabel: 'Disable anyway',
+ tone: 'danger',
+ }}
+ />
+ )
+
+ // Observable result (T4): what a screen reader announces as the dialog's
+ // description must include the impact details the operator must see before
+ // confirming a destructive action — not just the lead message.
+ const dialog = screen.getByRole('alertdialog')
+ expect(dialog).toHaveAccessibleDescription(
+ /Disabling this model would strand its references\.[\s\S]*Impacted: team-a\/reader, team-b\/writer/
+ )
+ })
+
+ it('leaves the description at the message alone when there are no details', () => {
+ render(<ConfirmHarness options={{ title: 'Confirm', message: 'Proceed with the change?' }} />)
+
+ const dialog = screen.getByRole('alertdialog')
+ expect(dialog).toHaveAccessibleDescription('Proceed with the change?')
+ })
+})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 45902cdb2..ce8768032 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.422",
+ "version": "0.1.423",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.422",
+ "version": "0.1.423",
"dependencies": {
"@clerum/llm-providers": "file:../packages/llm-providers",
"@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",
diff --git a/control-ui/package.json b/control-ui/package.json
index fd327fd2e..653ecf0fd 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.422",
+ "version": "0.1.423",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",