Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Aug 23, 2024
1 parent d0cdf2e commit 6ea6bfe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions frontend/src/lib/lemon-ui/Link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import './Link.scss'

import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { isExternalLink } from 'lib/utils'
import { getCurrentTeamId } from 'lib/utils/getAppContext'
Expand Down Expand Up @@ -96,9 +95,6 @@ export const Link: React.FC<LinkProps & React.RefAttributes<HTMLElement>> = Reac
href: typeof to === 'string' ? to : undefined,
})

const { sidePanelOpen } = useValues(sidePanelStateLogic)
const { openSidePanel } = useActions(sidePanelStateLogic)

const onClick = (event: React.MouseEvent<HTMLElement>): void => {
if (event.metaKey || event.ctrlKey) {
event.stopPropagation()
Expand All @@ -112,7 +108,13 @@ export const Link: React.FC<LinkProps & React.RefAttributes<HTMLElement>> = Reac
return
}

if (typeof to === 'string' && isPostHogComDocs(to)) {
const mountedSidePanelLogic = sidePanelStateLogic.findMounted()

if (typeof to === 'string' && isPostHogComDocs(to) && mountedSidePanelLogic) {
// TRICKY: We do this instead of hooks as there is some weird cyclic issue in tests
const { sidePanelOpen } = mountedSidePanelLogic.values
const { openSidePanel } = mountedSidePanelLogic.actions

event.preventDefault()

const target = event.currentTarget
Expand Down

0 comments on commit 6ea6bfe

Please sign in to comment.