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(data-warehouse): allow collapsing sidebar groups while searching (#65749)

Jovan Sakovic4303ac605f23
diff --git a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
index 3a8cb7f36186..0d32abce5167 100644
--- a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
@@ -1571,7 +1571,7 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
},
],
})),
- selectors(({ actions }) => ({
+ selectors(({ actions, cache }) => ({
hasNonPosthogSources: [
(s) => [s.dataWarehouseTables],
(dataWarehouseTables: DatabaseSchemaDataWarehouseTable[]): boolean => {
@@ -1944,10 +1944,13 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
searchResults.push(createTopLevelFolderNode('drafts', draftsChildren, true))
}
+ // Auto-expand matching groups once per search term, so the user can freely collapse
+ // them afterwards without the selector immediately re-expanding them.
const expandedIdSet = new Set(expandedSearchFolders)
const missingRequiredExpansion = expandedIds.some((id) => !expandedIdSet.has(id))
- if (missingRequiredExpansion) {
+ if (missingRequiredExpansion && cache.lastAutoExpandedSearchTerm !== searchTerm) {
+ cache.lastAutoExpandedSearchTerm = searchTerm
// Auto-expand only parent folders, not the matching nodes themselves.
setTimeout(() => {
actions.setExpandedSearchFolders(