:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(support): stop the support modal reopening from a stale URL hash (#88262)
Christiaan Hendriksen4292c09a79da
diff --git a/frontend/src/lib/components/Support/supportLogic.test.ts b/frontend/src/lib/components/Support/supportLogic.test.tsindex 789cc16a457c..bfda7b667b70 100644--- a/frontend/src/lib/components/Support/supportLogic.test.ts+++ b/frontend/src/lib/components/Support/supportLogic.test.ts@@ -1,3 +1,4 @@+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import posthog from 'posthog-js'@@ -74,6 +75,74 @@ describe('supportLogic', () => {})})+ describe('support panel URL hash lifecycle', () => {+ let logic: ReturnType<typeof supportLogic.build>++ beforeEach(() => {+ localStorage.clear()+ window.history.replaceState(null, '', '/')+ initKeaTests()+ sidePanelStateLogic.mount()+ logic = supportLogic.build()+ logic.mount()+ openSupportModal.mockClear()+ })++ afterEach(() => {+ logic?.unmount()+ })++ it('does not write the panel hash when the form opens as a modal', async () => {+ router.actions.push('/login', { next: '/home' })++ await expectLogic(logic, () => {+ logic.actions.openSupportForm({ kind: 'support', target: 'modal' })+ }).toFinishAllListeners()++ expect(router.values.hashParams['panel']).toBeUndefined()+ })++ it('clears a support deep-link hash on close when no side panel owns it', async () => {+ router.actions.push('/login', { next: '/home' }, { panel: 'support:support:false' })++ await expectLogic(logic, () => {+ logic.actions.openSupportForm({ kind: 'support', target: 'modal' })+ }).toFinishAllListeners()++ await expectLogic(logic, () => {+ logic.actions.closeSupportForm()+ }).toFinishAllListeners()++ expect(router.values.hashParams['panel']).toBeUndefined()+ expect(router.values.location.pathname).toBe('/login')+ expect(router.values.searchParams).toEqual({ next: '/home' })+ })++ it('clears the legacy supportModal hash on close when no side panel owns it', async () => {+ router.actions.push('/login', {}, { supportModal: 'support' })++ await expectLogic(logic, () => {+ logic.actions.openSupportForm({ kind: 'support', target: 'modal' })+ logic.actions.closeSupportForm()+ }).toFinishAllListeners()++ expect(router.values.hashParams['supportModal']).toBeUndefined()+ expect(router.values.hashParams['panel']).toBeUndefined()+ })++ it('leaves the panel hash alone on close when the side panel is available', async () => {+ sidePanelStateLogic.actions.setSidePanelAvailable(true)+ router.actions.push('/project/1/home', {}, { panel: 'support:support:false' })++ await expectLogic(logic, () => {+ logic.actions.openSupportForm({ kind: 'support', target: 'sidePanel' })+ logic.actions.closeSupportForm()+ }).toFinishAllListeners()++ expect(String(router.values.hashParams['panel'])).toContain('support')+ })+ })+describe('submitSupportTicket', () => {const FORM_FIELDS: SupportFormFields = {name: 'Max',diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.tsindex e11609c8bb96..04a2b4a3fe46 100644--- a/frontend/src/lib/components/Support/supportLogic.ts+++ b/frontend/src/lib/components/Support/supportLogic.ts@@ -1,6 +1,7 @@import { MakeLogicType, actions, connect, kea, listeners, path, props, reducers, selectors } from 'kea'import { forms } from 'kea-forms'import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from 'kea-forms'+import { router } from 'kea-router'import posthog from 'posthog-js'import { EMAIL_SUPPORT_BUTTON, lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'@@ -487,6 +488,10 @@ export const supportLogic = kea<supportLogicType>([}),listeners(({ actions, props, values }) => ({updateUrlParams: async () => {+ if (!values.sidePanelAvailable) {+ return+ }+// Only include non-text fields in the URL parameters// This prevents focus loss when typing in text fieldsconst panelOptions = [values.sendSupportRequest.kind ?? '', values.isEmailFormOpen ?? 'false'].join(':')@@ -646,6 +651,22 @@ export const supportLogic = kea<supportLogicType>([},closeSupportForm: () => {+ if (!values.sidePanelAvailable) {+ const hashParams = { ...router.values.hashParams }+ let changed = false+ if (String(hashParams['panel'] ?? '').split(':')[0] === SidePanelTab.Support) {+ delete hashParams['panel']+ changed = true+ }+ if ('supportModal' in hashParams) {+ delete hashParams['supportModal']+ changed = true+ }+ if (changed) {+ router.actions.replace(router.values.location.pathname, router.values.searchParams, hashParams)+ }+ }+// Form is only reset by explicit Cancel button or successful submissionprops.onClose?.()},