From c7f9e926b8f9ff96931a6da72f2847d5ffc4c264 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 6 Oct 2022 09:41:22 +0200 Subject: [PATCH] chore(nc-gui): focus input on project load --- .../nc-gui/pages/index/index/[projectId].vue | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/nc-gui/pages/index/index/[projectId].vue b/packages/nc-gui/pages/index/index/[projectId].vue index ede3bece09..188c89b6c9 100644 --- a/packages/nc-gui/pages/index/index/[projectId].vue +++ b/packages/nc-gui/pages/index/index/[projectId].vue @@ -5,21 +5,17 @@ import { extractSdkResponseErrorMsg, message, navigateTo, - nextTick, - onMounted, projectTitleValidator, reactive, ref, + tryOnMounted, useProject, useRoute, - useSidebar, } from '#imports' -useSidebar('nc-left-sidebar', { hasSidebar: false }) - const route = useRoute() -const { project, loadProject, updateProject, isLoading } = useProject() +const { project, loadProject, updateProject, isLoading, projectLoadedHook } = useProject() loadProject(false) @@ -48,18 +44,18 @@ const renameProject = async () => { } // select and focus title field on load -onMounted(async () => { +projectLoadedHook(async () => { formState.title = project.value.title as string - await nextTick(() => { + tryOnMounted(() => { // todo: replace setTimeout and follow better approach setTimeout(() => { const input = form.value?.$el?.querySelector('input[type=text]') - input.setSelectionRange(0, formState.title?.length) - input.focus() - }, 500) + + input.setSelectionRange(0, formState.title?.length) + }, 150) }) }) @@ -80,6 +76,7 @@ onMounted(async () => {