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.

feat(conversations): join filter clear buttons to dropdown triggers (#72356)

Xandera903c5f6a703
diff --git a/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx b/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx
index 6d21994c6a0c..fa6c0f688235 100644
--- a/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx
+++ b/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx
@@ -1,11 +1,12 @@
import { useActions, useValues } from 'kea'
import { useEffect, useState } from 'react'
-import { IconChevronDown, IconPlusSmall } from '@posthog/icons'
+import { IconPlusSmall } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonDropdown, LemonInput } from '@posthog/lemon-ui'
import { urls } from 'scenes/urls'
+import { clearFilterButtonProps } from '../clearFilterButtonProps'
import { AssigneeIconDisplay, AssigneeLabelDisplay, AssigneeResolver } from './AssigneeDisplay'
import { assigneeSelectLogic } from './assigneeSelectLogic'
import { Assignee, AssigneeFilterEntry, MAX_ASSIGNEE_FILTER_ENTRIES } from './types'
@@ -134,7 +135,12 @@ export function AssigneeMultiSelect({
</div>
}
>
- <LemonButton size="small" type="secondary" active={showPopover} sideIcon={<IconChevronDown />}>
+ <LemonButton
+ size="small"
+ type="secondary"
+ active={showPopover}
+ {...clearFilterButtonProps(value.length > 0 ? () => onChange([]) : null, 'Clear assignee filter')}
+ >
<TriggerLabel value={value} />
</LemonButton>
</LemonDropdown>
diff --git a/products/conversations/frontend/components/clearFilterButtonProps.tsx b/products/conversations/frontend/components/clearFilterButtonProps.tsx
new file mode 100644
index 000000000000..53f07d5bd07c
--- /dev/null
+++ b/products/conversations/frontend/components/clearFilterButtonProps.tsx
@@ -0,0 +1,20 @@
+import { IconChevronDown, IconX } from '@posthog/icons'
+import { SideAction } from '@posthog/lemon-ui'
+
+export function clearFilterButtonProps(
+ onClear: (() => void) | null,
+ tooltip: string
+): { sideAction: SideAction; sideIcon?: undefined } | { sideIcon: JSX.Element; sideAction?: undefined } {
+ return onClear
+ ? {
+ sideAction: {
+ icon: <IconX />,
+ tooltip,
+ onClick: (e) => {
+ e.stopPropagation()
+ onClear()
+ },
+ },
+ }
+ : { sideIcon: <IconChevronDown /> }
+}
diff --git a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
index 74ec45732cc4..8e87c08a9db6 100644
--- a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
+++ b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
@@ -3,7 +3,7 @@ import { useActions, useMountedLogic, useValues } from 'kea'
import { router } from 'kea-router'
import { useEffect, useMemo, useRef } from 'react'
-import { IconChevronDown, IconClock, IconRefresh, IconX } from '@posthog/icons'
+import { IconChevronDown, IconClock, IconRefresh } from '@posthog/icons'
import {
LemonBadge,
LemonButton,
@@ -38,6 +38,7 @@ import { ProductKey } from '~/queries/schema/schema-general'
import { AssigneeDisplay, AssigneeMultiSelect, AssigneeResolver } from '../../components/Assignee'
import { ChannelsTag } from '../../components/Channels/ChannelsTag'
+import { clearFilterButtonProps } from '../../components/clearFilterButtonProps'
import { ComposeTicketButton } from '../../components/ComposeTicket'
import { ConversationsDisabledBanner } from '../../components/ConversationsDisabledBanner'
import { IdentityBadge } from '../../components/IdentityBadge/IdentityBadge'
@@ -505,7 +506,14 @@ export function SupportTicketsTableFilters(): JSX.Element {
</div>
}
>
- <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ {...clearFilterButtonProps(
+ statusFilter.length > 0 ? () => setStatusFilter([]) : null,
+ 'Clear status filter'
+ )}
+ >
{statusFilter.length === 0
? 'All statuses'
: statusFilter.length === 1
@@ -542,7 +550,14 @@ export function SupportTicketsTableFilters(): JSX.Element {
</div>
}
>
- <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ {...clearFilterButtonProps(
+ priorityFilter.length > 0 ? () => setPriorityFilter([]) : null,
+ 'Clear priority filter'
+ )}
+ >
{priorityFilter.length === 0
? 'All priorities'
: priorityFilter.length === 1
@@ -628,7 +643,14 @@ export function SupportTicketsTableFilters(): JSX.Element {
</div>
}
>
- <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ {...clearFilterButtonProps(
+ aiTriageResultFilter.length > 0 ? () => setAiTriageResultFilter([]) : null,
+ 'Clear AI result filter'
+ )}
+ >
{aiTriageResultFilter.length === 0
? 'All AI results'
: aiTriageResultFilter.length === 1
@@ -679,7 +701,19 @@ export function SupportTicketsTableFilters(): JSX.Element {
</div>
}
>
- <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ {...clearFilterButtonProps(
+ tagsFilter.length > 0 || tagsExcludeFilter.length > 0
+ ? () => {
+ setTagsFilter([])
+ setTagsExcludeFilter([])
+ }
+ : null,
+ 'Clear tag filter'
+ )}
+ >
{tagsFilter.length === 0 && tagsExcludeFilter.length === 0
? 'All tags'
: [
@@ -693,18 +727,6 @@ export function SupportTicketsTableFilters(): JSX.Element {
.join(', ')}
</LemonButton>
</LemonDropdown>
- {(tagsFilter.length > 0 || tagsExcludeFilter.length > 0) && (
- <LemonButton
- type="secondary"
- size="small"
- icon={<IconX />}
- onClick={() => {
- setTagsFilter([])
- setTagsExcludeFilter([])
- }}
- tooltip="Clear tag filter"
- />
- )}
<AssigneeMultiSelect value={assigneeFilterEntries} onChange={setAssigneeFilter} />
</div>
<div className="flex items-center gap-2">