diff --git a/web/default/src/features/keys/components/api-key-group-combobox.tsx b/web/default/src/features/keys/components/api-key-group-combobox.tsx index 0b0e38fe..968f7a6f 100644 --- a/web/default/src/features/keys/components/api-key-group-combobox.tsx +++ b/web/default/src/features/keys/components/api-key-group-combobox.tsx @@ -128,7 +128,12 @@ export function ApiKeyGroupCombobox({ - + event.stopPropagation()} + onTouchMove={(event) => event.stopPropagation()} + onPointerDown={(event) => event.stopPropagation()} + > ({ resolver: zodResolver(apiKeyFormSchema), - defaultValues: API_KEY_FORM_DEFAULT_VALUES, + defaultValues: getApiKeyFormDefaultValues(defaultUseAutoGroup), }) // Load existing data when updating @@ -156,9 +159,9 @@ export function ApiKeysMutateDrawer({ }) } else if (open && !isUpdate) { // For create, reset to defaults - form.reset(API_KEY_FORM_DEFAULT_VALUES) + form.reset(getApiKeyFormDefaultValues(defaultUseAutoGroup)) } - }, [open, isUpdate, currentRow, form]) + }, [open, isUpdate, currentRow, form, defaultUseAutoGroup]) const onSubmit = async (data: ApiKeyFormValues) => { setIsSubmitting(true) diff --git a/web/default/src/features/keys/constants.ts b/web/default/src/features/keys/constants.ts index 435d808d..632b3aa7 100644 --- a/web/default/src/features/keys/constants.ts +++ b/web/default/src/features/keys/constants.ts @@ -56,7 +56,7 @@ export const API_KEY_STATUS_OPTIONS = Object.values(API_KEY_STATUSES).map( // Default Values // ============================================================================ -export const DEFAULT_GROUP = 'auto' as const +export const DEFAULT_GROUP = '' as const // ============================================================================ // Error Messages (i18n keys: use t(ERROR_MESSAGES.xxx) when displaying) diff --git a/web/default/src/features/keys/lib/api-key-form.ts b/web/default/src/features/keys/lib/api-key-form.ts index 1c4ef006..60f4c678 100644 --- a/web/default/src/features/keys/lib/api-key-form.ts +++ b/web/default/src/features/keys/lib/api-key-form.ts @@ -37,6 +37,16 @@ export const API_KEY_FORM_DEFAULT_VALUES: ApiKeyFormValues = { tokenCount: 1, } +export function getApiKeyFormDefaultValues( + defaultUseAutoGroup: boolean +): ApiKeyFormValues { + return { + ...API_KEY_FORM_DEFAULT_VALUES, + group: defaultUseAutoGroup ? 'auto' : DEFAULT_GROUP, + cross_group_retry: defaultUseAutoGroup, + } +} + // ============================================================================ // Form Data Transformation // ============================================================================ diff --git a/web/default/src/features/keys/lib/index.ts b/web/default/src/features/keys/lib/index.ts index 1f9301b2..e0fb9a9c 100644 --- a/web/default/src/features/keys/lib/index.ts +++ b/web/default/src/features/keys/lib/index.ts @@ -5,6 +5,7 @@ export { apiKeyFormSchema, type ApiKeyFormValues, API_KEY_FORM_DEFAULT_VALUES, + getApiKeyFormDefaultValues, transformFormDataToPayload, transformApiKeyToFormDefaults, } from './api-key-form'