fix: gate registry fetch on modal visibility, use resetFields to clear OAuth fields

This commit is contained in:
Ishaan Jaffer 2026-03-10 13:55:24 -07:00
parent 36829d02ef
commit ceccbf110f
2 changed files with 6 additions and 6 deletions

View file

@ -37,13 +37,13 @@ const OpenAPIFormSection: React.FC<OpenAPIFormSectionProps> = ({
updates.auth_type = AUTH_TYPE.OAUTH2;
updates.authorization_url = entry.oauth.authorization_url;
updates.token_url = entry.oauth.token_url;
form.setFieldsValue(updates);
} else {
// Clear stale OAuth config from previous preset selection
updates.auth_type = undefined;
updates.authorization_url = undefined;
updates.token_url = undefined;
// resetFields is required to visually clear Ant Design form fields —
// setFieldsValue with undefined silently skips undefined keys.
form.resetFields(["auth_type", "authorization_url", "token_url"]);
form.setFieldsValue(updates);
}
form.setFieldsValue(updates);
onValuesChange(updates);
};

View file

@ -619,7 +619,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
{transportType === TRANSPORT.OPENAPI && (
<OpenAPIFormSection
form={form}
accessToken={accessToken}
accessToken={isModalVisible ? accessToken : null}
onValuesChange={(updates) =>
setFormValues((prev) => ({ ...prev, ...updates }))
}