File tree Expand file tree Collapse file tree
components/composite/StepComplete Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import PaymentSource from "@commercelayer/react-components/payment_source/Paymen
22import PaymentSourceBrandIcon from "@commercelayer/react-components/payment_source/PaymentSourceBrandIcon"
33import PaymentSourceBrandName from "@commercelayer/react-components/payment_source/PaymentSourceBrandName"
44import PaymentSourceDetail from "@commercelayer/react-components/payment_source/PaymentSourceDetail"
5- import { useContext , useEffect , useState } from "react"
5+ import { useContext , useEffect , useRef } from "react"
66import { Trans , useTranslation } from "react-i18next"
77
88import { OrderSummary } from "components/composite/OrderSummary"
@@ -59,13 +59,22 @@ export const StepComplete: React.FC<Props> = ({
5959 const { t } = useTranslation ( )
6060
6161 const ctx = useContext ( AppContext )
62+ const topRef = useRef < HTMLDivElement | null > ( null )
6263
6364 useEffect ( ( ) => {
6465 if ( thankyouPageUrl != null ) {
6566 window . location . href = thankyouPageUrl
6667 }
6768 } , [ thankyouPageUrl ] )
6869
70+ useEffect ( ( ) => {
71+ if ( topRef . current != null ) {
72+ topRef . current . scrollIntoView ( {
73+ behavior : "smooth" ,
74+ } )
75+ }
76+ } , [ topRef . current ] )
77+
6978 if ( ! ctx ) return null
7079
7180 const handleClick = ( ) => {
@@ -77,7 +86,7 @@ export const StepComplete: React.FC<Props> = ({
7786 return (
7887 thankyouPageUrl == null && (
7988 < Base >
80- < Top >
89+ < Top ref = { topRef } >
8190 < Wrapper >
8291 < Logo
8392 logoUrl = { logoUrl }
You can’t perform that action at this time.
0 commit comments