From 197dc3647123b5cf0c2f824ac3c40dfecdd6f0e3 Mon Sep 17 00:00:00 2001 From: nncluzu Date: Fri, 10 Jan 2025 12:18:41 +0100 Subject: [PATCH] front: scroll into warning box Signed-off-by: nncluzu --- .../stdcm/components/StdcmWarningBox.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/src/applications/stdcm/components/StdcmWarningBox.tsx b/front/src/applications/stdcm/components/StdcmWarningBox.tsx index 46364b0f77b..9fcfa9ba0df 100644 --- a/front/src/applications/stdcm/components/StdcmWarningBox.tsx +++ b/front/src/applications/stdcm/components/StdcmWarningBox.tsx @@ -1,3 +1,5 @@ +import { useEffect, useRef } from 'react'; + import { Button } from '@osrd-project/ui-core'; import { Alert } from '@osrd-project/ui-icons'; import cx from 'classnames'; @@ -25,8 +27,16 @@ const StdcmWarningBox = ({ removeDestinationArrivalTime, }: StdcmWarningBoxProps) => { const { t } = useTranslation('stdcm'); + const ref = useRef(null); + + useEffect(() => { + if (errorType && errorType !== StdcmConfigErrorTypes.MISSING_LOCATION && ref.current) { + ref.current.scrollIntoView({ behavior: 'smooth' }); + } + }, [errorType]); + return ( -
+