From 67ea922811194be7694004d94495fa346c329360 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 13 May 2024 10:27:37 +0200 Subject: [PATCH] scroll top on component mount --- src/components/game/GameAnswerExplanation.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/game/GameAnswerExplanation.jsx b/src/components/game/GameAnswerExplanation.jsx index 23e3b4e..6ab8634 100644 --- a/src/components/game/GameAnswerExplanation.jsx +++ b/src/components/game/GameAnswerExplanation.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { useGame } from "../../hooks/useGame"; import sucessIcon from "../../assets/img/icons/behaviour-type-success.svg"; @@ -7,6 +7,9 @@ import { useUser } from "../../hooks/useUser"; import Loading from "../animations/Loading"; export default function GameAnwerExplanation({ questionId }) { + useEffect(() => { + document.querySelector("dialog").scrollTo(0, 0); + },[]); const { answers, contextGameDatas, setCurrentGameModal, checkIfGameIsComplete } = useGame(); const { screensTranslations } = useUser(); @@ -19,7 +22,7 @@ export default function GameAnwerExplanation({ questionId }) { contextGameDatas.gameObjects[questionId].attrs.objectBehaviourDescription ?? "Pas d'explication pour cette question"; const objectPictureUrl = contextGameDatas.gameObjects[questionId].attrs.objectPictureUrl; - + return (