Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Nov 14, 2023
1 parent 7e9f7ef commit 170a95b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const SidePanelDocs = (): JSX.Element => {
targetBlank
onClick={() => closeSidePanel()}
>
Open on posthog.com
Open in new tab
</LemonButton>
</SidePanelPaneHeader>
<div className="relative flex-1">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actions, kea, reducers, path, listeners, connect, selectors } from 'kea'
import { actions, kea, reducers, path, listeners, connect, selectors, afterMount, beforeUnmount } from 'kea'

import type { sidePanelDocsLogicType } from './sidePanelDocsLogicType'
import { sidePanelStateLogic } from '../sidePanelStateLogic'
Expand Down Expand Up @@ -75,12 +75,20 @@ export const sidePanelDocsLogic = kea<sidePanelDocsLogicType>([
unmountIframe: () => {
// Update the initialPath so that next time we load it is the same as last time
actions.setInitialPath(values.currentPath ?? '/docs')

// TODO: Do we need to call this before the window unloads?
},

handleExternalUrl: ({ urlOrPath }) => {
router.actions.push(getPathFromUrl(urlOrPath))
},
})),

afterMount(({ actions, cache }) => {
// Call actions.unmountIframe when the window unloads
cache.beforeUnload = () => actions.unmountIframe()
window.addEventListener('beforeunload', cache.beforeUnload)
}),

beforeUnmount(({ cache }) => {
window.removeEventListener('beforeunload', cache.beforeUnload)
}),
])

0 comments on commit 170a95b

Please sign in to comment.