Skip to content

Commit

Permalink
fix: use window location instead of next router
Browse files Browse the repository at this point in the history
  • Loading branch information
MaGOs92 committed Dec 5, 2024
1 parent e8e6531 commit 8149a84
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/contexts/BALWidget.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useCallback, useEffect, useRef, useState, createContext } from 'react'
import styled, { css } from 'styled-components'
import { matomoTrackEvent } from '@/lib/matomo'
import { env } from 'next-runtime-env'
import { useRouter } from 'next/navigation'

export const StyledIFrame = styled.iframe<{ $isOpen: boolean, $isVisible: boolean }>`
position: fixed;
Expand Down Expand Up @@ -53,7 +52,6 @@ interface BALWidgetProviderProps {

export function BALWidgetProvider({ children }: BALWidgetProviderProps) {
const balWidgetRef = useRef<HTMLIFrameElement>(null)
const router = useRouter()
const transitionTimeout = useRef<NodeJS.Timeout>()
const [isWidgetDisplayed, setIsWidgetDisplayed] = useState(false)
const [isWidgetVisible, setIsWidgetVisible] = useState(true)
Expand Down Expand Up @@ -161,7 +159,7 @@ export function BALWidgetProvider({ children }: BALWidgetProviderProps) {
setIsBalWidgetConfigLoaded(true)
break
case 'BAL_WIDGET_PARENT_NAVIGATE_TO':
router.push(event.data.content)
window.location.href = event.data.content
break
default:
break
Expand All @@ -175,7 +173,7 @@ export function BALWidgetProvider({ children }: BALWidgetProviderProps) {
window.removeEventListener('message', BALWidgetMessageHandler)
clearTimeout(transitionTimeout.current)
}
}, [isBalWidgetOpen, router])
}, [isBalWidgetOpen])

return (
<BALWidgetContext.Provider value={{
Expand Down

0 comments on commit 8149a84

Please sign in to comment.