Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10225-fixed-1708720961774.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Linode storage Volume Create Drawer crash ([#10225](https://github.com/linode/manager/pull/10225))
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TagsInput } from 'src/components/TagsInput/TagsInput';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';
import { MAX_VOLUME_SIZE } from 'src/constants';
import { useFormValidateOnChange } from 'src/hooks/useFormValidateOnChange';

@hkhalil-akamai hkhalil-akamai Feb 27, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope of this PR, but this hook seems unnecessary as opposed to useState

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I've thought about this hook, maybe not worth the abstraction, but also thought about how it kindly improves form nomenclature consistency across formik forms as opposed to declaring a randomly named piece of state each time.

import { useEventsPollingActions } from 'src/queries/events/events';
import { useGrants, useProfile } from 'src/queries/profile';
import { useCreateVolumeMutation } from 'src/queries/volumes';
Expand Down Expand Up @@ -56,6 +57,10 @@ export const LinodeVolumeCreateForm = (props: Props) => {
const { data: profile } = useProfile();
const { data: grants } = useGrants();
const { mutateAsync: createVolume } = useCreateVolumeMutation();
const {
hasFormBeenSubmitted,
setHasFormBeenSubmitted,
} = useFormValidateOnChange();

const { checkForNewEvents } = useEventsPollingActions();

Expand Down Expand Up @@ -90,6 +95,7 @@ export const LinodeVolumeCreateForm = (props: Props) => {
size: maybeCastToNumber(size),
tags,
});
setHasFormBeenSubmitted(false);
checkForNewEvents();
enqueueSnackbar(`Volume scheduled for creation.`, {
variant: 'success',
Expand All @@ -99,6 +105,7 @@ export const LinodeVolumeCreateForm = (props: Props) => {
// Analytics Event
sendCreateVolumeEvent(`Size: ${size}GB`, origin);
} catch (error) {
setHasFormBeenSubmitted(true);
handleFieldErrors(setErrors, error);
handleGeneralErrors(
setStatus,
Expand All @@ -107,6 +114,8 @@ export const LinodeVolumeCreateForm = (props: Props) => {
);
}
},
validateOnBlur: false,
validateOnChange: hasFormBeenSubmitted,
validationSchema: CreateVolumeSchema,
});

Expand Down Expand Up @@ -205,6 +214,7 @@ export const LinodeVolumeCreateForm = (props: Props) => {
disabled,
label: 'Create Volume',
loading: isSubmitting,
onClick: () => setHasFormBeenSubmitted(true),
type: 'submit',
}}
secondaryButtonProps={{
Expand Down