Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: focus secret key with environments first (#8321)

Andrew Huangb91129d120f1
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index c008285e69..b009244536 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -3568,7 +3568,13 @@ const OverviewPageContent = () => {
open={popUp.addSecretsInAllEnvs.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("addSecretsInAllEnvs", isOpen)}
>
- <SheetContent className="flex h-full min-h-0 flex-col gap-y-0 overflow-hidden sm:max-w-lg">
+ <SheetContent
+ className="flex h-full min-h-0 flex-col gap-y-0 overflow-hidden sm:max-w-lg"
+ onOpenAutoFocus={(event) => {
+ event.preventDefault();
+ document.getElementById("create-secret-0-key")?.focus();
+ }}
+ >
<SheetHeader className="border-b">
<SheetTitle>Create Secret</SheetTitle>
</SheetHeader>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx
index 765c812f4a..7785daa51b 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx
@@ -413,6 +413,43 @@ export const CreateSecretForm = ({
className="flex min-h-0 flex-1 flex-col overflow-hidden"
>
<div className="flex thin-scrollbar flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <Controller
+ control={control}
+ name="environments"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="create-secret-environments">Environments</FieldLabel>
+ <FieldContent>
+ <Combobox
+ id="create-secret-environments"
+ multiple
+ options={environments.filter((environment) =>
+ permission.can(
+ ProjectPermissionSecretActions.Create,
+ subject(ProjectPermissionSub.Secrets, {
+ environment: environment.slug,
+ secretPath,
+ secretName: "*",
+ secretTags: ["*"]
+ })
+ )
+ )}
+ value={value}
+ onValueChange={onChange}
+ isError={Boolean(error)}
+ modal
+ placeholder="Select environments to create secret in..."
+ searchPlaceholder="Search environments..."
+ searchAriaLabel="Search environments"
+ emptyMessage="No environments found."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.slug}
+ />
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
{secretFields.map((secretField, index) => {
const secretKey = watch(`secrets.${index}.key`);
const metadata = watch(`secrets.${index}.metadata`) ?? [];
@@ -454,7 +491,6 @@ export const CreateSecretForm = ({
onBlur={field.onBlur}
placeholder="Type your secret name"
onPaste={(event) => handlePaste(event, index)}
- autoFocus={index === 0}
autoComplete="off"
isError={Boolean(error)}
className={currentProject?.autoCapitalization ? "uppercase" : undefined}
@@ -849,43 +885,6 @@ export const CreateSecretForm = ({
<PlusIcon className="size-4" />
Add More
</Button>
- <Controller
- control={control}
- name="environments"
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="create-secret-environments">Environments</FieldLabel>
- <FieldContent>
- <Combobox
- id="create-secret-environments"
- multiple
- options={environments.filter((environment) =>
- permission.can(
- ProjectPermissionSecretActions.Create,
- subject(ProjectPermissionSub.Secrets, {
- environment: environment.slug,
- secretPath,
- secretName: "*",
- secretTags: ["*"]
- })
- )
- )}
- value={value}
- onValueChange={onChange}
- isError={Boolean(error)}
- modal
- placeholder="Select environments to create secret in..."
- searchPlaceholder="Search environments..."
- searchAriaLabel="Search environments"
- emptyMessage="No environments found."
- getOptionLabel={(option) => option.name}
- getOptionValue={(option) => option.slug}
- />
- <FieldError errors={[error]} />
- </FieldContent>
- </Field>
- )}
- />
</div>
<SheetFooter className="justify-between border-t">
{onUploadSecrets && (