Skip to content

Commit

Permalink
fix(insights): Do not show prompt to confirm leaving if opening sidep…
Browse files Browse the repository at this point in the history
…anel (#20707)
  • Loading branch information
webjunkie authored Mar 5, 2024
1 parent efca1a6 commit 55e584c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frontend/src/scenes/insights/insightSceneLogic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { actions, BuiltLogic, connect, kea, listeners, path, reducers, selectors, sharedListeners } from 'kea'
import { actionToUrl, beforeUnload, router, urlToAction } from 'kea-router'
import { CombinedLocation } from 'kea-router/lib/utils'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { eventUsageLogic, InsightEventSource } from 'lib/utils/eventUsageLogic'
import { createEmptyInsight, insightLogic } from 'scenes/insights/insightLogic'
Expand Down Expand Up @@ -269,7 +270,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
}
}),
beforeUnload(({ values }) => ({
enabled: () => {
enabled: (newLocation?: CombinedLocation) => {
// safeguard against running this check on other scenes
if (values.activeScene !== Scene.Insight) {
return false
Expand All @@ -280,6 +281,11 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
return false
}

// If just the hash changes, don't show the prompt
if (router.values.currentLocation.pathname === newLocation?.pathname) {
return false
}

return (
values.insightMode === ItemMode.Edit &&
(!!values.insightLogicRef?.logic.values.insightChanged ||
Expand Down

0 comments on commit 55e584c

Please sign in to comment.