From 7d49c3e8bc6b9cec271f9758ae2262b567aff1d8 Mon Sep 17 00:00:00 2001 From: Vasilii Mikhailovskii Date: Mon, 9 Dec 2024 09:51:04 +0200 Subject: [PATCH] improvement scroll to section & focus in create --- apps/frontend/src/components/create/CreateSection.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/frontend/src/components/create/CreateSection.vue b/apps/frontend/src/components/create/CreateSection.vue index 3338fd4..8eb2ddd 100644 --- a/apps/frontend/src/components/create/CreateSection.vue +++ b/apps/frontend/src/components/create/CreateSection.vue @@ -16,13 +16,14 @@ watch( () => sectionRef.value && props.isNextActiveSection, (isNextActiveSection) => { if (isNextActiveSection) { - sectionRef.value?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + const isSM = window.matchMedia('(min-width: 640px)').matches + sectionRef.value?.scrollIntoView({ behavior: 'smooth', block: isSM ? 'center' : 'start' }) - const input = sectionRef.value?.querySelector('input[type="text"]') + const input = sectionRef.value?.querySelector('input[type="text"][value=""]') if (input instanceof HTMLInputElement) { setTimeout(() => { input.focus() - }, 200) + }, 400) } } },