Skip to content

Commit 8027efb

Browse files
committed
scroll to top if errors are present
1 parent dcb2466 commit 8027efb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ export const CreateWorkspacePageView: FC<
7575
// to disappear.
7676
setGitAuthErrors({})
7777
}, [props.templateGitAuth])
78+
79+
const workspaceErrors =
80+
props.createWorkspaceErrors[CreateWorkspaceErrors.CREATE_WORKSPACE_ERROR]
81+
82+
// Scroll to top of page if errors are present
83+
useEffect(() => {
84+
if (props.hasTemplateErrors || Boolean(workspaceErrors)) {
85+
window.scrollTo(0, 0)
86+
}
87+
}, [props.hasTemplateErrors, workspaceErrors])
88+
7889
const { t } = useTranslation("createWorkspacePage")
7990
const styles = useStyles()
8091

0 commit comments

Comments
 (0)