Skip to content

: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.

fix(feature-flags): keep list filters when returning via the breadcrumb (#124507)

ruby childsedb6b6e02785
diff --git a/frontend/src/scenes/feature-flags/FeatureFlags.tsx b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
index c4898984142f..18a9f7b60627 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlags.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
@@ -1,5 +1,4 @@
import { useActions, useValues } from 'kea'
-import { combineUrl } from 'kea-router'
import { useEffect, useRef, useState } from 'react'
import { IconArchive, IconLock, IconPlusSmall, IconTrash } from '@posthog/icons'
@@ -82,7 +81,13 @@ import { BulkDeleteResultsModal } from './BulkDeleteResultsModal'
import { openBulkArchiveFlagsDialog, openFeatureFlagArchiveDialog } from './featureFlagArchiveDialog'
import { openFeatureFlagDeleteDialog } from './featureFlagDeleteDialog'
import { FeatureFlagFiltersSection } from './FeatureFlagFilters'
-import { FLAGS_PER_PAGE, FeatureFlagsTab, featureFlagsLogic, flagMatchesType } from './featureFlagsLogic'
+import {
+ FLAGS_PER_PAGE,
+ FeatureFlagsTab,
+ featureFlagUrlFromList,
+ featureFlagsLogic,
+ flagMatchesType,
+} from './featureFlagsLogic'
import { BULK_ARCHIVE_MAX_FLAGS, flagSelectionLogic } from './flagSelectionLogic'
import { OverlayForNewFeatureFlagMenu } from './NewFeatureFlagMenu'
import ProjectsGrid from './projects-grid/ProjectsGrid'
@@ -192,7 +197,7 @@ function WarningStatusTag({ label, heading, detail }: { label: string; heading:
function FeatureFlagRowActions({ featureFlag }: { featureFlag: FeatureFlagType }): JSX.Element {
const { currentProjectId } = useValues(projectLogic)
const flagLogic = featureFlagsLogic({})
- const { featureFlagsUpdating } = useValues(flagLogic)
+ const { featureFlagsUpdating, filters } = useValues(flagLogic)
const { toggleFeatureFlagActive, updateFeatureFlagArchived, loadFeatureFlags } = useActions(flagLogic)
const isUpdating = featureFlag.id ? featureFlagsUpdating[featureFlag.id] : false
@@ -229,7 +234,11 @@ function FeatureFlagRowActions({ featureFlag }: { featureFlag: FeatureFlagType }
overlay={
<>
{featureFlag.id && (
- <LemonButton to={urls.featureFlag(featureFlag.id)} data-attr="feature-flag-view" fullWidth>
+ <LemonButton
+ to={featureFlagUrlFromList(featureFlag.id, filters)}
+ data-attr="feature-flag-view"
+ fullWidth
+ >
View
</LemonButton>
)}
@@ -256,7 +265,7 @@ function FeatureFlagRowActions({ featureFlag }: { featureFlag: FeatureFlagType }
? "You don't have permission to edit this feature flag."
: null
}
- to={combineUrl(urls.featureFlag(featureFlag.id), { edit: true }).url}
+ to={featureFlagUrlFromList(featureFlag.id, filters, { edit: true })}
>
Edit
</LemonButton>
@@ -463,7 +472,13 @@ export function OverviewTab({
render: function Render(_, featureFlag: FeatureFlagType) {
return (
<LemonTableLink
- to={featureFlag.id ? urls.featureFlag(featureFlag.id) : undefined}
+ to={
+ featureFlag.id
+ ? // Carry the list's filters on the flag URL, so the detail page's
+ // breadcrumb and back arrow return to this view of the list
+ featureFlagUrlFromList(featureFlag.id, filters)
+ : undefined
+ }
title={
<>
<span>{stringWithWBR(featureFlag.key, 17)}</span>
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
index fb2c7a0d7231..89ed84609ca1 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
@@ -9,7 +9,7 @@ import {
} from 'lib/api.mock'
import { render } from '@testing-library/react'
-import { router } from 'kea-router'
+import { combineUrl, router } from 'kea-router'
import { expectLogic, partial } from 'kea-test-utils'
import posthog from 'posthog-js'
import { toast } from 'react-toastify'
@@ -18,6 +18,7 @@ import { lemonToast as sharedLemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { ApiError, NetworkError } from 'lib/api-error'
+import { activityLogLogic } from 'lib/components/ActivityLog/activityLogLogic'
import { flagTriggerLogic } from 'lib/components/IngestionControls/triggers/FlagTrigger/flagTriggerLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
@@ -35,6 +36,7 @@ import { deleteFromTree, refreshTreeItem } from '~/layout/panel-layout/ProjectTr
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import {
+ ActivityScope,
CohortPropertyFilter,
CohortType,
FeatureFlagGroupType,
@@ -85,7 +87,7 @@ import {
validateFeatureFlagVariantKey,
validateVariantRolloutSum,
} from './featureFlagLogic'
-import { FeatureFlagsTab, featureFlagsLogic } from './featureFlagsLogic'
+import { FeatureFlagsTab, featureFlagUrlFromList, featureFlagsLogic } from './featureFlagsLogic'
jest.mock('posthog-js')
@@ -291,6 +293,58 @@ describe('featureFlagLogic', () => {
jest.useRealTimers()
})
+ describe('breadcrumbs', () => {
+ it('hands list filter params carried on the flag URL back to the list crumb', async () => {
+ await expectLogic(logic, () => {
+ router.actions.push(urls.featureFlag(1), {
+ list_search: 'checkout',
+ list_created_by_id: '[42]',
+ edit: 'true',
+ })
+ }).toFinishAllListeners()
+
+ const listCrumb = logic.values.breadcrumbs[0]
+ expect(listCrumb.path).toContain(`${urls.featureFlags()}?`)
+ expect(listCrumb.path).toContain('search=checkout')
+ expect(listCrumb.path).toContain('created_by_id=%5B42%5D')
+ expect(listCrumb.path).not.toContain('list_')
+ expect(listCrumb.path).not.toContain('edit=')
+ })
+
+ it('links the list crumb to the bare list URL when the flag URL carries no filters', async () => {
+ await expectLogic(logic, () => {
+ router.actions.push(urls.featureFlag(1))
+ }).toFinishAllListeners()
+
+ expect(logic.values.breadcrumbs[0].path).toBe(urls.featureFlags())
+ })
+ })
+
+ describe('carried list params on the flag page', () => {
+ it('shows history page 1 when the flag is opened from list page 3', async () => {
+ useMocks({
+ get: {
+ [`/api/projects/${MOCK_DEFAULT_PROJECT.id}/feature_flags/${MOCK_FEATURE_FLAG.id}/activity/`]:
+ () => [200, { results: [], next: null }],
+ },
+ })
+ const activityLogic = activityLogLogic({ scope: ActivityScope.FEATURE_FLAG, id: MOCK_FEATURE_FLAG.id })
+ activityLogic.mount()
+
+ try {
+ await expectLogic(activityLogic, () => {
+ router.actions.push(featureFlagUrlFromList(MOCK_FEATURE_FLAG.id, { page: 3 }, { tab: 'history' }))
+ }).toFinishAllListeners()
+
+ // The list's page rides as `list_page`, so the History tab's own pagination
+ // (which reads the bare `page` param) starts at page 1
+ expect(activityLogic.values.page).toBe(1)
+ } finally {
+ activityLogic.unmount()
+ }
+ })
+ })
+
describe('stale list-cache reconciliation on mount', () => {
it.each([
{
@@ -1175,6 +1229,24 @@ describe('featureFlagLogic', () => {
}
})
+ it('keeps the carried list filter params when the flag page saves', async () => {
+ router.actions.push(urls.featureFlag(MOCK_FEATURE_FLAG.id), { list_search: 'checkout', edit: 'true' })
+ await expectLogic(logic).toFinishAllListeners()
+ const replaceSpy = jest.spyOn(router.actions, 'replace')
+
+ try {
+ await expectLogic(logic, () => {
+ logic.actions.saveFeatureFlagSuccess(logic.values.featureFlag)
+ }).toFinishAllListeners()
+
+ expect(replaceSpy).toHaveBeenCalledWith(
+ combineUrl(urls.featureFlag(MOCK_FEATURE_FLAG.id), { list_search: 'checkout' }).url
+ )
+ } finally {
+ replaceSpy.mockRestore()
+ }
+ })
+
it('keeps the current route when an embedded editor saves a feature flag', async () => {
const notebookUrl = urls.notebook('embedded-flag')
router.actions.push(notebookUrl)
@@ -1236,6 +1308,24 @@ describe('featureFlagLogic', () => {
})
})
+ it('keeps the carried list filter params when a save needs approval', async () => {
+ router.actions.push(urls.featureFlag(MOCK_FEATURE_FLAG.id), { list_search: 'checkout', edit: true })
+ await expectLogic(logic).toFinishAllListeners()
+ logic.actions.setFeatureFlag({ ...logic.values.featureFlag, name: 'Unapproved name' })
+ jest.spyOn(api, 'update').mockRejectedValueOnce(approvalRequired())
+ jest.spyOn(sharedLemonToast, 'info').mockReturnValue('toast-id')
+
+ await expectLogic(logic, () => {
+ logic.actions.saveFeatureFlag(logic.values.featureFlag)
+ })
+ .toDispatchActions(['saveFeatureFlagFailure', 'loadFeatureFlagSuccess'])
+ .toFinishAllListeners()
+
+ // The edit param falls away, but the list filters still ride for the breadcrumb
+ expect(router.values.searchParams.edit).toBeUndefined()
+ expect(router.values.searchParams.list_search).toBe('checkout')
+ })
+
it('opens the change request when creating a flag needs approval, and leaves the form clean', async () => {
router.actions.push(urls.featureFlag('new'))
const newLogic = featureFlagLogic({ id: 'new' })
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
index fc6b5507dfef..053ebb87352c 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
@@ -19,7 +19,7 @@ import type { BreakPointFunction } from 'kea'
import { DeepPartialMap, ValidationErrorType, forms } from 'kea-forms'
import type { DeepPartial, FieldName } from 'kea-forms'
import { loaders } from 'kea-loaders'
-import { beforeUnload, router, urlToAction } from 'kea-router'
+import { beforeUnload, combineUrl, router, urlToAction } from 'kea-router'
import { CombinedLocation } from 'kea-router/lib/utils'
import posthog from 'posthog-js'
import { toast } from 'react-toastify'
@@ -45,7 +45,13 @@ import { capitalizeFirstLetter, humanList, slugify } from 'lib/utils/strings'
import { showApprovalRequiredToast } from 'scenes/approvals/ApprovalRequiredBanner'
import { dispatchChangeRequestCreated } from 'scenes/approvals/utils'
import { experimentLogic } from 'scenes/experiments/experimentLogic'
-import { FeatureFlagsTab, featureFlagsLogic, isFeatureFlagsTab } from 'scenes/feature-flags/featureFlagsLogic'
+import {
+ FeatureFlagsTab,
+ carriedListFilterParams,
+ featureFlagsLogic,
+ isFeatureFlagsTab,
+ listFilterParamsFromCarried,
+} from 'scenes/feature-flags/featureFlagsLogic'
import { projectLogic } from 'scenes/projectLogic'
import { Scene } from 'scenes/sceneTypes'
import { NEW_SURVEY, NewSurvey, SURVEY_CREATED_SOURCE } from 'scenes/surveys/constants'
@@ -2511,7 +2517,7 @@ export interface featureFlagLogicMeta {
featureFlag: FeatureFlagType,
aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
) => string
- breadcrumbs: (featureFlag: FeatureFlagType) => Breadcrumb[]
+ breadcrumbs: (featureFlag: FeatureFlagType, searchParams: Record<string, any>) => Breadcrumb[]
projectTreeRef: (arg: number | 'link' | 'new') => ProjectTreeRef
sidePanelContext: (featureFlag: FeatureFlagType) => SidePanelSceneContext | null
recordingFilterForFlag: (featureFlag: FeatureFlagType) => Partial<RecordingUniversalFilters>
@@ -4479,7 +4485,12 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
actions.updateFlag(featureFlag)
actions.loadFeatureFlagStatus()
if (featureFlag.id && isOnFeatureFlagPage(props.id)) {
- router.actions.replace(urls.featureFlag(featureFlag.id))
+ // Keep the list filter params from the flag URL through the post-save redirect,
+ // so the breadcrumb still returns to the filtered list. Only `list_`-prefixed
+ // params are carried, so a new flag's creation presets (`type`, `properties`)
+ // fall away here on their own.
+ const listParams = carriedListFilterParams(router.values.searchParams)
+ router.actions.replace(combineUrl(urls.featureFlag(featureFlag.id), listParams).url)
}
actions.editFeatureFlag(false)
@@ -4527,7 +4538,11 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
if (flagId) {
// The unsaved-changes guard compares against the router's pathname, which carries the
// project prefix that urls.featureFlag() lacks. Reuse it so the guard sees the same page.
- router.actions.replace(router.values.location.pathname)
+ // Keep the carried list filter params, so the breadcrumb still returns to the filtered list.
+ router.actions.replace(
+ router.values.location.pathname,
+ carriedListFilterParams(router.values.searchParams)
+ )
actions.editFeatureFlag(false)
// The edit waits in the change request, so the page shows the stored flag again.
actions.loadFeatureFlag()
@@ -5485,12 +5500,17 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
},
],
breadcrumbs: [
- (s) => [s.featureFlag],
- (featureFlag: FeatureFlagType): Breadcrumb[] => [
+ (s) => [s.featureFlag, router.selectors.searchParams],
+ (featureFlag: FeatureFlagType, searchParams: Record<string, any>): Breadcrumb[] => [
{
key: Scene.FeatureFlags,
name: 'Feature Flags',
- path: urls.featureFlags(),
+ // A flag's URL carries the list's filter params (`list_`-prefixed) when opened
+ // from the list. Hand them back, so this crumb (and the scene back arrow, which
+ // follows the same path) returns to the view the user left. A new flag's URL
+ // params are unprefixed creation presets (`type`, `properties`), so they stay
+ // out of the crumb on their own.
+ path: combineUrl(urls.featureFlags(), listFilterParamsFromCarried(searchParams)).url,
iconType: 'feature_flag',
},
{
diff --git a/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts
index c726ba677305..6a0474d46d25 100644
--- a/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts
@@ -1,4 +1,4 @@
-import { router } from 'kea-router'
+import { combineUrl, router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
@@ -13,9 +13,13 @@ import { NEW_FLAG } from 'scenes/feature-flags/featureFlagLogic'
import {
FeatureFlagsFilters,
FeatureFlagsTab,
+ carriedListFilterParams,
+ featureFlagUrlFromList,
+ featureFlagsListFilterParams,
featureFlagsLogic,
flagMatchesFilters,
flagMatchesSearch,
+ listFilterParamsFromCarried,
flagMatchesStatus,
flagMatchesType,
} from 'scenes/feature-flags/featureFlagsLogic'
@@ -352,6 +356,105 @@ describe('the feature flags logic', () => {
})
})
+ describe('carrying list filters through a flag detail page (featureFlagsListFilterParams)', () => {
+ it('returns no params while the filters are at their defaults', () => {
+ // Both default shapes: page 1 after mount, page undefined after a bare-URL visit
+ expect(featureFlagsListFilterParams(logic.values.filters)).toEqual({})
+ expect(featureFlagsListFilterParams({ page: undefined })).toEqual({})
+ })
+
+ it('keeps filter params, drops page 1, and ignores non-filter params', () => {
+ expect(
+ featureFlagsListFilterParams({
+ search: 'checkout',
+ created_by_id: '[42]',
+ page: '1',
+ tab: 'overview',
+ edit: 'true',
+ })
+ ).toEqual({ search: 'checkout', created_by_id: '[42]' })
+ expect(featureFlagsListFilterParams({ page: 3 })).toEqual({ page: 3 })
+ })
+
+ it('carries filters on the flag URL under the list_ prefix, clear of detail-page params', () => {
+ const url = featureFlagUrlFromList(1, { search: 'checkout', page: 3 }, { edit: true })
+ expect(url).toContain('list_search=checkout')
+ expect(url).toContain('list_page=3')
+ expect(url).toContain('edit=true')
+ // The flag page's own params stay unshadowed: History pagination reads bare `page`
+ expect(url).not.toMatch(/[?&]page=/)
+ expect(url).not.toMatch(/[?&]search=/)
+ })
+
+ it('round-trips carried params back into list filter params', () => {
+ const flagPageParams = { list_search: 'checkout', list_page: '3', tab: 'history', page: '2' }
+ expect(carriedListFilterParams(flagPageParams)).toEqual({ list_search: 'checkout', list_page: '3' })
+ expect(listFilterParamsFromCarried(flagPageParams)).toEqual({ search: 'checkout', page: '3' })
+ })
+
+ it('restores search, creator, and sort filters when the crumb hands them back', async () => {
+ await expectLogic(logic, () => {
+ logic.actions.setFeatureFlagsFilters({
+ search: 'checkout',
+ created_by_id: [42],
+ order: '-created_at',
+ })
+ }).toFinishAllListeners()
+
+ // Opening a flag carries the filters on the detail URL. The same helper builds the
+ // key link, View, and Edit URLs in FeatureFlags.tsx, so this covers all three.
+ const detailUrl = featureFlagUrlFromList(1, logic.values.filters)
+ await expectLogic(logic, () => {
+ router.actions.push(detailUrl)
+ }).toFinishAllListeners()
+
+ // The scene swap remounts the list logic, so its in-memory filters reset
+ logic.unmount()
+ logic = featureFlagsLogic()
+ logic.mount()
+ expect(logic.values.filters.search).toBeUndefined()
+
+ // The detail scene's list crumb rebuilds the list URL from the carried params
+ const crumbUrl = combineUrl(
+ urls.featureFlags(),
+ listFilterParamsFromCarried(router.values.searchParams)
+ ).url
+ await expectLogic(logic, () => {
+ router.actions.push(crumbUrl)
+ }).toFinishAllListeners()
+
+ expect(logic.values.filters.search).toBe('checkout')
+ expect(logic.values.filters.created_by_id).toEqual([42])
+ expect(logic.values.filters.order).toBe('-created_at')
+ })
+
+ it('resets to defaults when the bare list URL is visited directly', async () => {
+ await expectLogic(logic, () => {
+ logic.actions.setFeatureFlagsFilters({ search: 'checkout', created_by_id: [42] })
+ }).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ router.actions.push(urls.featureFlags())
+ }).toFinishAllListeners()
+
+ expect(logic.values.filters.search).toBeUndefined()
+ expect(logic.values.filters.created_by_id).toBeUndefined()
+ expect(logic.values.hasActiveFilters).toBe(false)
+ })
+
+ it('lets explicit URL params win over in-memory filters', async () => {
+ await expectLogic(logic, () => {
+ logic.actions.setFeatureFlagsFilters({ search: 'checkout' })
+ }).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ router.actions.push(urls.featureFlags(), { search: 'onboarding' })
+ }).toFinishAllListeners()
+
+ expect(logic.values.filters.search).toBe('onboarding')
+ })
+ })
+
it('redirects a disabled usage deep link to overview after flags load', async () => {
enabledFeaturesLogic.actions.setFeatureFlags([], {})
diff --git a/frontend/src/scenes/feature-flags/featureFlagsLogic.ts b/frontend/src/scenes/feature-flags/featureFlagsLogic.ts
index fff10989b255..3c5e0ef845a2 100644
--- a/frontend/src/scenes/feature-flags/featureFlagsLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagsLogic.ts
@@ -1,6 +1,6 @@
import { MakeLogicType, actions, connect, kea, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
-import { actionToUrl, router, urlToAction } from 'kea-router'
+import { actionToUrl, combineUrl, router, urlToAction } from 'kea-router'
import { LemonDialog, PaginationManual, lemonToast } from '@posthog/lemon-ui'
@@ -8,7 +8,7 @@ import api, { CountedPaginatedResponse } from 'lib/api'
import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic as enabledFeaturesLogic, FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
-import { objectsEqual } from 'lib/utils/objects'
+import { objectClean, objectsEqual } from 'lib/utils/objects'
import { parseNumericArrayFilter, parseTagsFilter, toParams } from 'lib/utils/url'
import { handleFlagApprovalRequired } from 'scenes/feature-flags/updateFlagActiveInProject'
import { projectLogic } from 'scenes/projectLogic'
@@ -183,6 +183,68 @@ const DEFAULT_FILTERS: FeatureFlagsFilters = {
excluded_tags: undefined,
}
+const FILTER_PARAM_KEYS = Object.keys(DEFAULT_FILTERS) as (keyof FeatureFlagsFilters)[]
+
+/**
+ * Prefix for the list's filter params while they ride on a flag detail URL. The prefix keeps them
+ * out of the way of the detail page's own params — most importantly `page`, which the History tab's
+ * activityLogLogic reads for its pagination.
+ */
+const CARRIED_FILTER_PARAM_PREFIX = 'list_'
+
+/**
+ * The list's filter params found in `filters` or in the list URL's search params. A flag opened
+ * from the list carries them (prefixed) in its own URL, and the detail scene's list breadcrumb
+ * hands them back, so returning that way restores the view the user left. They ride in the URL
+ * because sceneLogic unmounts the list scene's logic before it mounts the flag scene's logic, so
+ * the flag logic's connection to `featureFlagsLogic` mounts a new copy with default filters.
+ */
+export function featureFlagsListFilterParams(searchParams: Record<string, any>): Record<string, any> {
+ const params = objectClean(Object.fromEntries(FILTER_PARAM_KEYS.map((key) => [key, searchParams[key]])))
+ // Page 1 is the default view, so leave the param out and keep default URLs bare
+ if (String(params.page) === '1') {
+ delete params.page
+ }
+ return params
+}
+
+/** A flag detail URL that carries the list's current filters as `list_`-prefixed params. */
+export function featureFlagUrlFromList(
+ id: number | string,
+ filters: Record<string, any>,
+ extraParams: Record<string, any> = {}
+): string {
+ const carried = Object.fromEntries(
+ Object.entries(featureFlagsListFilterParams(filters)).map(([key, value]) => [
+ CARRIED_FILTER_PARAM_PREFIX + key,
+ value,
+ ])
+ )
+ return combineUrl(urls.featureFlag(id), { ...carried, ...extraParams }).url
+}
+
+/** The `list_`-prefixed params on a flag page's URL, as-is, for redirects that stay on the flag page. */
+export function carriedListFilterParams(searchParams: Record<string, any>): Record<string, any> {
+ return objectClean(
+ Object.fromEntries(
+ FILTER_PARAM_KEYS.map((key) => [
+ CARRIED_FILTER_PARAM_PREFIX + key,
+ searchParams[CARRIED_FILTER_PARAM_PREFIX + key],
+ ])
+ )
+ )
+}
+
+/** The carried params translated back into the list's own filter params, for the list breadcrumb. */
+export function listFilterParamsFromCarried(searchParams: Record<string, any>): Record<string, any> {
+ return Object.fromEntries(
+ Object.entries(carriedListFilterParams(searchParams)).map(([key, value]) => [
+ key.slice(CARRIED_FILTER_PARAM_PREFIX.length),
+ value,
+ ])
+ )
+}
+
export interface FlagLogicProps {
flagPrefix?: string // used to filter flags by prefix e.g. for the user interview flags
}