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

🔎 fix: Focus Credential Inputs in Agent Tools (#11394)

Dustin Healy9134471143cd
diff --git a/client/src/components/MCP/CustomUserVarsSection.tsx b/client/src/components/MCP/CustomUserVarsSection.tsx
index 987613e24c..339b78f6b9 100644
--- a/client/src/components/MCP/CustomUserVarsSection.tsx
+++ b/client/src/components/MCP/CustomUserVarsSection.tsx
@@ -23,9 +23,10 @@ interface AuthFieldProps {
hasValue: boolean;
control: any;
errors: any;
+ autoFocus?: boolean;
}
-function AuthField({ name, config, hasValue, control, errors }: AuthFieldProps) {
+function AuthField({ name, config, hasValue, control, errors, autoFocus }: AuthFieldProps) {
const localize = useLocalize();
const statusText = hasValue ? localize('com_ui_set') : localize('com_ui_unset');
@@ -85,6 +86,11 @@ function AuthField({ name, config, hasValue, control, errors }: AuthFieldProps)
<Input
id={name}
type="text"
+ /* autoFocus is generally disabled due to the fact that it can disorient users,
+ * but in this case, the required field would logically be immediately navigated to anyways, and the component's
+ * functionality emulates that of a new modal opening, where users would expect focus to be shifted to the new content */
+ // eslint-disable-next-line jsx-a11y/no-autofocus
+ autoFocus={autoFocus}
{...field}
placeholder={
hasValue
@@ -150,7 +156,7 @@ export default function CustomUserVarsSection({
return (
<div className="flex-1 space-y-4">
<form onSubmit={handleSubmit(onFormSubmit)} className="space-y-4">
- {Object.entries(fields).map(([key, config]) => {
+ {Object.entries(fields).map(([key, config], index) => {
const hasValue = authValuesData?.authValueFlags?.[key] || false;
return (
@@ -161,6 +167,8 @@ export default function CustomUserVarsSection({
hasValue={hasValue}
control={control}
errors={errors}
+ // eslint-disable-next-line jsx-a11y/no-autofocus -- See AuthField autoFocus comment for more details
+ autoFocus={index === 0}
/>
);
})}
diff --git a/client/src/components/Plugins/Store/PluginAuthForm.tsx b/client/src/components/Plugins/Store/PluginAuthForm.tsx
index f6eec0a6af..5af1948c11 100644
--- a/client/src/components/Plugins/Store/PluginAuthForm.tsx
+++ b/client/src/components/Plugins/Store/PluginAuthForm.tsx
@@ -56,6 +56,11 @@ function PluginAuthForm({ plugin, onSubmit, isEntityTool }: TPluginAuthFormProps
aria-describedby={`${authField}-error`}
aria-label={config.label}
aria-required="true"
+ /* autoFocus is generally disabled due to the fact that it can disorient users,
+ * but in this case, the required field must be navigated to anyways, and the component's functionality
+ * emulates that of a new modal opening, where users would expect focus to be shifted to the new content */
+ // eslint-disable-next-line jsx-a11y/no-autofocus
+ autoFocus={i === 0}
{...register(authField, {
required: `${config.label} is required.`,
minLength: {
@@ -70,7 +75,7 @@ function PluginAuthForm({ plugin, onSubmit, isEntityTool }: TPluginAuthFormProps
</HoverCard>
{errors[authField] && (
<span role="alert" className="mt-1 text-sm text-red-400">
- {errors?.[authField]?.message ?? ''}
+ {String(errors?.[authField]?.message ?? '')}
</span>
)}
</div>