Skip to content

fix: keep "workspace create" form when rendering errors #7289

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 3 commits into from
Apr 27, 2023

Conversation

bpmct
Copy link
Member

@bpmct bpmct commented Apr 26, 2023

fixes #7286

What is the best way to scroll up the page when a user submits and there is an error? Right now, it's hard to tell if there is an error on the top of the page.

Screen.Recording.2023-04-25.at.8.03.05.PM.mov

@Kira-Pilot
Copy link
Member

@bpmct nice job!!!!
To get the window to scroll up, you're going to want to add a useEffect in the component body (above the JSX). Something like:

const workspaceErrors = props.createWorkspaceErrors[CreateWorkspaceErrors.CREATE_WORKSPACE_ERROR]

useEffect(() => {
    if (props.hasTemplateErrors || Boolean(workspaceErrors)) {
        window.scrollTo(0,0)
    }
}, [props.hasTemplateErrors, workspaceErrors])

This above basically says "If a template error appears or if a workspace error appears while this component is mounted in the tree, scroll to the top of the page".

Let me know if that doesn't get you want! I briefly tested it out but port 3000 is being weird for some reason so I had to use 8080.

@bpmct
Copy link
Member Author

bpmct commented Apr 27, 2023

Nice. I hesitated to use window.scrollTo since I didn't see it in other places in the codebase. I see the same behavior with the templates page, so I'll add that in another PR.

Screen.Recording.2023-04-27.at.11.21.28.AM.mov

@bpmct bpmct enabled auto-merge (squash) April 27, 2023 16:24
@bpmct bpmct merged commit fe323a1 into main Apr 27, 2023
@bpmct bpmct deleted the bpmct/delete-workspace-error branch April 27, 2023 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"workspace name already exists" error removes the Create Workspace UI
2 participants