From 092dc7fc49246580023a8b97101d51845c81bf04 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 31 Mar 2023 11:17:55 +0700
Subject: iframe content

---
 src/core/components/elements/Link/Link.jsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/core/components/elements/Link/Link.jsx')

diff --git a/src/core/components/elements/Link/Link.jsx b/src/core/components/elements/Link/Link.jsx
index 75fc6ca8..557abbc4 100644
--- a/src/core/components/elements/Link/Link.jsx
+++ b/src/core/components/elements/Link/Link.jsx
@@ -1,10 +1,18 @@
 import NextLink from 'next/link'
+import { useRouter } from 'next/router'
+import { useEffect } from 'react'
 
 const Link = ({ children, ...props }) => {
+  const router = useRouter()
+
+  useEffect(() => {
+    router.events.on('routeChangeStart', () => window.scrollTo({ top: 0, behavior: 'smooth' }))
+  }, [router])
+
   return (
     <NextLink
       {...props}
-      onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
+      // onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
       scroll={false}
       className={`block font-medium text-red_r-11 ${props?.className || ''}`}
     >
-- 
cgit v1.2.3

