Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

♿ a11y: Stop Agent API Keys Dialog Opening Its Info Card On Focus (#16735)

Marco Beretta5424837b7b5c
diff --git a/client/src/components/Nav/SettingsTabs/ApiKeys/ApiKeys.tsx b/client/src/components/Nav/SettingsTabs/ApiKeys/ApiKeys.tsx
index 4c0d6cbecd..70c684036e 100644
--- a/client/src/components/Nav/SettingsTabs/ApiKeys/ApiKeys.tsx
+++ b/client/src/components/Nav/SettingsTabs/ApiKeys/ApiKeys.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { useRef, useState } from 'react';
import { Plus } from 'lucide-react';
import {
Label,
@@ -19,6 +19,14 @@ export default function ApiKeys() {
const localize = useLocalize();
const [open, setOpen] = useState(false);
const [createOpen, setCreateOpen] = useState(false);
+ const contentRef = useRef<HTMLDivElement>(null);
+
+ /** Without this, Radix focuses the first focusable element, the info hover card
+ * trigger, which opens its card on focus as soon as the dialog opens. */
+ const handleOpenAutoFocus = (event: Event) => {
+ event.preventDefault();
+ contentRef.current?.focus();
+ };
return (
<div className="flex items-center justify-between">
@@ -30,7 +38,11 @@ export default function ApiKeys() {
</Button>
</OGDialogTrigger>
<OGDialogContent
- className="w-11/12 max-w-2xl bg-surface-dialog text-text-primary shadow-2xl"
+ focusOutline="hidden"
+ ref={contentRef}
+ tabIndex={-1}
+ onOpenAutoFocus={handleOpenAutoFocus}
+ className="bg-surface-dialog text-text-primary w-11/12 max-w-2xl shadow-2xl"
aria-describedby={undefined}
>
<OGDialogHeader className="space-y-0 pr-8 text-left">
diff --git a/client/src/components/Nav/SettingsTabs/ApiKeys/__tests__/ApiKeys.spec.tsx b/client/src/components/Nav/SettingsTabs/ApiKeys/__tests__/ApiKeys.spec.tsx
index a803448f4b..dd53a9b434 100644
--- a/client/src/components/Nav/SettingsTabs/ApiKeys/__tests__/ApiKeys.spec.tsx
+++ b/client/src/components/Nav/SettingsTabs/ApiKeys/__tests__/ApiKeys.spec.tsx
@@ -61,6 +61,16 @@ describe('ApiKeys', () => {
expect(getByText('Connect your agents to external apps')).toBeInTheDocument();
});
+ it('does not open the info hover card when the dialog opens', () => {
+ const { queryByText } = openManageDialog();
+ expect(queryByText(/API keys let external apps and tools/)).not.toBeInTheDocument();
+ });
+
+ it('moves initial focus to the dialog content instead of the info trigger', () => {
+ const { getByRole } = openManageDialog();
+ expect(document.activeElement).toBe(getByRole('dialog'));
+ });
+
it('opens the create dialog from within the management dialog', () => {
const { getAllByRole, getByRole } = openManageDialog();
fireEvent.click(getAllByRole('button', { name: 'Create API Key' })[0]);