Skip to content

Commit ee528da

Browse files
fix: autofocus
1 parent 983d366 commit ee528da

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

frontend/components/environments/CreateEnvironmentDialog.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export const CreateEnvironmentDialog = (props: { appId: string }) => {
5555
const [createEnvironment, { loading }] = useMutation(CreateEnv)
5656

5757
const [name, setName] = useState('')
58+
5859
const dialogRef = useRef<{ closeModal: () => void }>(null)
60+
const inputRef = useRef(null)
5961

6062
const handleSubmit = async (event: { preventDefault: () => void }) => {
6163
event.preventDefault()
@@ -125,6 +127,7 @@ export const CreateEnvironmentDialog = (props: { appId: string }) => {
125127
<FaPlus /> New Environment
126128
</div>
127129
}
130+
initialFocus={inputRef}
128131
>
129132
<form className="space-y-4 py-4" onSubmit={handleSubmit}>
130133
<div>
@@ -142,7 +145,7 @@ export const CreateEnvironmentDialog = (props: { appId: string }) => {
142145
label="Environment name"
143146
required
144147
maxLength={32}
145-
data-autofocus
148+
ref={inputRef}
146149
/>
147150
<p className="text-xs text-neutral-500">
148151
Use up to 32 characters. Only letters, numbers, hyphens and underscores allowed.

frontend/components/environments/ManageEnvironmentDialog.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ const RenameEnvironment = (props: { environment: EnvironmentType }) => {
6969
? 'Upgrade to Pro to rename Environments'
7070
: "You don't have the permissions required to rename this Environment"}
7171
</Alert>
72-
72+
7373
<div className="space-y-2">
7474
<Input
7575
value={sanitizeInput(name)}
7676
setValue={setName}
7777
label="Environment name"
7878
required
7979
maxLength={32}
80-
data-autofocus
8180
disabled={!allowRename}
8281
/>
8382
{allowRename && (
@@ -86,7 +85,7 @@ const RenameEnvironment = (props: { environment: EnvironmentType }) => {
8685
</p>
8786
)}
8887
</div>
89-
88+
9089
{allowRename && (
9190
<div className="flex justify-end">
9291
<Button type="submit" variant="primary" disabled={name === props.environment.name}>

0 commit comments

Comments
 (0)