Skip to content

Commit 196f1c6

Browse files
committed
fix(unit-user-usage): disable autofocus on project form on this page only
1 parent d7a1881 commit 196f1c6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

components/projects/CreateProjectForm.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface CreateProjectFormProps {
4444
>;
4545
unitId: UnitDetail["id"] | (() => Promise<UnitDetail["id"]>);
4646
product?: ProductDetail;
47+
autoFocus?: boolean;
4748
}
4849

4950
export interface Values {
@@ -54,7 +55,12 @@ export interface Values {
5455

5556
type ProjectFormikProps = FormikConfig<Values>;
5657

57-
export const CreateProjectForm = ({ modal, unitId, product }: CreateProjectFormProps) => {
58+
export const CreateProjectForm = ({
59+
modal,
60+
unitId,
61+
product,
62+
autoFocus = true,
63+
}: CreateProjectFormProps) => {
5864
const initialValues: Values = {
5965
projectName: "",
6066
flavour: product?.flavour ?? DEFAULT_PRODUCT_FLAVOUR,
@@ -145,7 +151,13 @@ export const CreateProjectForm = ({ modal, unitId, product }: CreateProjectFormP
145151
gap: 1,
146152
}}
147153
>
148-
<Field autoFocus fullWidth component={TextField} label="Project Name" name="projectName" />
154+
<Field
155+
fullWidth
156+
autoFocus={autoFocus}
157+
component={TextField}
158+
label="Project Name"
159+
name="projectName"
160+
/>
149161

150162
{isError ? (
151163
<Typography color="error">{getErrorMessage(error)}</Typography>

components/usage/UnitUserUsage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const UnitUserUsage = ({ unitId }: UnitUserUsageProps) => {
112112
</Box>
113113

114114
<Typography variant="h4">Create Project</Typography>
115-
<CreateProjectForm unitId={unit.id} />
115+
<CreateProjectForm autoFocus={false} unitId={unit.id} />
116116
</Container>
117117
);
118118
};

0 commit comments

Comments
 (0)