Skip to content

Commit

Permalink
front: scroll into warning box
Browse files Browse the repository at this point in the history
Signed-off-by: nncluzu <[email protected]>
  • Loading branch information
kmer2016 committed Jan 17, 2025
1 parent 00df2a1 commit 91c7153
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion front/src/applications/stdcm/components/StdcmWarningBox.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -25,8 +27,16 @@ const StdcmWarningBox = ({
removeDestinationArrivalTime,
}: StdcmWarningBoxProps) => {
const { t } = useTranslation('stdcm');
const ref = useRef<HTMLDivElement>(null);

useEffect(() => {
if (errorType && errorType !== StdcmConfigErrorTypes.MISSING_LOCATION && ref.current) {
ref.current.scrollIntoView({ behavior: 'smooth' });
}
}, [errorType]);

return (
<div data-testid="warning-box" className="warning-box">
<div ref={ref} data-testid="warning-box" className="warning-box">
<span>
<Alert variant="fill" size="lg" />
</span>
Expand Down

0 comments on commit 91c7153

Please sign in to comment.