From 30421ae13dc155ab9374fc6e6ef393c360e66ed3 Mon Sep 17 00:00:00 2001 From: Aprillion Date: Thu, 6 Jul 2023 13:17:24 +0200 Subject: [PATCH] scroll to top AFTER a question is added to top of state --- app/hooks/useQuestionStateInUrl.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/hooks/useQuestionStateInUrl.ts b/app/hooks/useQuestionStateInUrl.ts index 2579d7ef..e6286fa0 100644 --- a/app/hooks/useQuestionStateInUrl.ts +++ b/app/hooks/useQuestionStateInUrl.ts @@ -124,9 +124,12 @@ export default function useQuestionStateInUrl(minLogo: boolean, initialQuestions } const moveToTop = (currentState: string, {pageid}: Question) => { - window.scrollTo({ - top: 0, - behavior: 'smooth', + setTimeout(() => { + // scroll to top after the state is updated + window.scrollTo({ + top: 0, + behavior: 'smooth', + }) }) return moveQuestionToTop(currentState, pageid) }