Skip to content

fix: clear workspace name validation on field dirty #10927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2023
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
fix: clear workspace name validation on field dirty
  • Loading branch information
Kira-Pilot committed Nov 28, 2023
commit d16b4ac6679d836d3610f364286efec7a1ef41b4
1 change: 1 addition & 0 deletions site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const CreateWorkspacePage: FC = () => {
defaultOwner={me}
defaultBuildParameters={defaultBuildParameters}
error={createWorkspaceMutation.error}
resetMutation={createWorkspaceMutation.reset}
Copy link
Collaborator

Choose a reason for hiding this comment

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

For me, resetMutation does not say too much about its intention. Maybe resetError could be a better name?

template={templateQuery.data!}
versionId={realizedVersionId}
externalAuth={externalAuth ?? []}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Language = {
export interface CreateWorkspacePageViewProps {
mode: CreateWorkspaceMode;
error: unknown;
resetMutation: () => void;
defaultName: string;
defaultOwner: TypesGen.User;
template: TypesGen.Template;
Expand All @@ -67,6 +68,7 @@ export interface CreateWorkspacePageViewProps {
export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
mode,
error,
resetMutation,
defaultName,
defaultOwner,
template,
Expand Down Expand Up @@ -157,7 +159,8 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
<TextField
{...getFieldHelpers("name")}
disabled={creatingWorkspace}
onChange={onChangeTrimmed(form)}
// resetMutation facilitates the clearing of validation errors
onChange={onChangeTrimmed(form, resetMutation)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not have to reset the mutation to clear the form error. But I think it is probably out of scope since it looks to be an issue with how we use the getFormHelpers gets the errors.

autoFocus
fullWidth
label="Workspace Name"
Expand Down