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(workflows): apply list filters from links to the workflows tab url (#118405)

Meikel Ratz56302604f7d1
diff --git a/frontend/src/lib/components/MemberSelect.tsx b/frontend/src/lib/components/MemberSelect.tsx
index ae7241acbefc..d58fa2b73d09 100644
--- a/frontend/src/lib/components/MemberSelect.tsx
+++ b/frontend/src/lib/components/MemberSelect.tsx
@@ -1,5 +1,5 @@
import { useActions, useValues } from 'kea'
-import { useMemo, useState } from 'react'
+import { useEffect, useMemo, useState } from 'react'
import { LemonButton, LemonButtonProps, LemonDropdown, LemonDropdownProps, LemonInput } from '@posthog/lemon-ui'
@@ -63,6 +63,14 @@ export function MemberSelect({
return meFirstMembers.find((member) => member.user[propToCompare] === value)?.user ?? null
}, [value, meFirstMembers, propToCompare])
+ // Load members when a value is set even before the popover opens, so a value pre-populated
+ // from the URL resolves to a name rather than falling back to the default label.
+ useEffect(() => {
+ if (value && !selectedMemberAsUser && !options) {
+ ensureAllMembersLoaded()
+ }
+ }, [value]) // oxlint-disable-line react-hooks/exhaustive-deps
+
const handleVisibilityChange = (visible: boolean): void => {
setShowPopover(visible)
if (searchValue && !options) {
diff --git a/products/workflows/frontend/Workflows/workflowsLogic.test.ts b/products/workflows/frontend/Workflows/workflowsLogic.test.ts
new file mode 100644
index 000000000000..1955c170a27b
--- /dev/null
+++ b/products/workflows/frontend/Workflows/workflowsLogic.test.ts
@@ -0,0 +1,37 @@
+import { router } from 'kea-router'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { workflowsLogic } from './workflowsLogic'
+
+describe('workflowsLogic', () => {
+ let logic: ReturnType<typeof workflowsLogic.build>
+
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/environments/:team_id/hog_flows/': { results: [], count: 0 },
+ '/api/projects/:team_id/hog_flows/': { results: [], count: 0 },
+ },
+ })
+ initKeaTests()
+ logic = workflowsLogic()
+ logic.mount()
+ })
+
+ afterEach(() => logic.unmount())
+
+ it.each(['/workflows', '/workflows/workflows'])('fills the filters from the query params on %s', (path) => {
+ router.actions.push(`${path}?created_by=user-uuid&status=active&trigger_type=event&type=messaging`)
+
+ expect(logic.values.filters).toEqual({
+ search: '',
+ createdBy: 'user-uuid',
+ status: 'active',
+ type: 'messaging',
+ triggerType: 'event',
+ page: 1,
+ })
+ })
+})
diff --git a/products/workflows/frontend/Workflows/workflowsLogic.ts b/products/workflows/frontend/Workflows/workflowsLogic.ts
index cae00bb36dfe..7dfa787fedd1 100644
--- a/products/workflows/frontend/Workflows/workflowsLogic.ts
+++ b/products/workflows/frontend/Workflows/workflowsLogic.ts
@@ -543,8 +543,8 @@ export const workflowsLogic = kea<workflowsLogicType>([
setFilters: buildURL,
}
}),
- urlToAction(({ actions, values }) => ({
- [urls.workflows()]: (_, searchParams) => {
+ urlToAction(({ actions, values }) => {
+ const syncFiltersFromUrl = (_: Record<string, any>, searchParams: Record<string, any>): void => {
const status = searchParams['status']
const type = searchParams['type']
const triggerType = searchParams['trigger_type']
@@ -561,6 +561,11 @@ export const workflowsLogic = kea<workflowsLogicType>([
if (!objectsEqual(parsed, values.filters)) {
actions.setFilters(parsed, true)
}
- },
- })),
+ }
+ // The list renders on both the bare scene URL and its explicit tab URL, so shared links work from either.
+ return {
+ [urls.workflows()]: syncFiltersFromUrl,
+ [urls.workflows('workflows')]: syncFiltersFromUrl,
+ }
+ }),
])