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(dashboards): keep clear tags action visible (#95279)

Matt Pua9603b694f872
diff --git a/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.test.tsx b/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.test.tsx
index aa007b036fbc..eea8f37c3fd8 100644
--- a/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.test.tsx
+++ b/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.test.tsx
@@ -67,4 +67,28 @@ describe('DashboardsFiltersBar', () => {
expect(screen.getAllByText('Loading…')).toHaveLength(5)
})
+
+ it('clears all selected tags from the tag picker', () => {
+ const setFilters = jest.fn()
+ ;(useActions as jest.Mock).mockReturnValue({
+ loadMoreTagResults: jest.fn(),
+ setFilters,
+ setTagSearch: jest.fn(),
+ setShowTagPopover: jest.fn(),
+ setSearch: jest.fn(),
+ })
+ ;(useValues as jest.Mock).mockReturnValue({
+ filters: { createdBy: 'All users', search: '', tags: ['growth', 'analytics'] },
+ currentTab: DashboardsTab.All,
+ tagPageLoading: false,
+ tagResults: ['growth', 'analytics'],
+ tagSearch: '',
+ showTagPopover: true,
+ })
+
+ render(<DashboardsFiltersBar />)
+ fireEvent.click(document.querySelector('[data-attr="dashboard-tags-clear-selection"]')!)
+
+ expect(setFilters).toHaveBeenCalledWith({ tags: [] })
+ })
})
diff --git a/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.tsx b/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.tsx
index ad1803dc8e1d..323efa675c6e 100644
--- a/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.tsx
+++ b/frontend/src/scenes/dashboard/dashboards/DashboardsFiltersBar.tsx
@@ -28,7 +28,6 @@ export function DashboardsFiltersBar({ extraActions }: DashboardsFiltersBarProps
}
setFilters({ tags: Array.from(selected) })
}
-
return (
<div className="flex justify-between gap-2 flex-wrap mb-4">
<LemonInput type="search" placeholder="Search for dashboards" onChange={setSearch} value={filters.search} />
@@ -62,6 +61,18 @@ export function DashboardsFiltersBar({ extraActions }: DashboardsFiltersBarProps
fullWidth
className="max-w-full"
/>
+ {(filters.tags?.length || 0) > 0 && (
+ <LemonButton
+ data-attr="dashboard-tags-clear-selection"
+ fullWidth
+ role="menuitem"
+ size="small"
+ onClick={() => setFilters({ tags: [] })}
+ type="tertiary"
+ >
+ Clear selection
+ </LemonButton>
+ )}
<div
ref={tagListScrollRef}
className="max-h-80 overflow-y-auto"
@@ -108,20 +119,6 @@ export function DashboardsFiltersBar({ extraActions }: DashboardsFiltersBarProps
) : null}
</ul>
</div>
- {(filters.tags?.length || 0) > 0 && (
- <>
- <div className="my-1 border-t" />
- <LemonButton
- fullWidth
- role="menuitem"
- size="small"
- onClick={() => setFilters({ tags: [] })}
- type="tertiary"
- >
- Clear selection
- </LemonButton>
- </>
- )}
</div>
}
>