: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(insights): select the current series in the picker (#104448)
Paul D'Ambra3df4dc7d1588
diff --git a/docs/internal/taxonomic-filter-search.md b/docs/internal/taxonomic-filter-search.mdindex 2beaed590ae9..e27cd2623238 100644--- a/docs/internal/taxonomic-filter-search.md+++ b/docs/internal/taxonomic-filter-search.md@@ -19,6 +19,7 @@ The legacy implementation separates these requests in `infiniteListLogic.ts`; thEvent-only insight editors and closed breakdown pickers do not load the action list.Action series load their definitions to resolve names and event-scoped properties.Opening an event picker that offers Actions loads the list; later opens reuse the shared cache.+When an insight series picker opens on Suggested series, the current selection is the first and selected item. All events follows it.The classic popover unmounts after its close transition and starts with a fresh search when reopened.## Typing and renderingdiff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsxindex d2473697185c..0a5b12b44be6 100644--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx@@ -40,6 +40,7 @@ export function TaxonomicFilter({selectedProperties,popoverEnabled = true,selectFirstItem = true,+ promoteSelectedItemToFirstPosition,propertyAllowList,hideBehavioralCohorts,showCohortFlagTargeting,@@ -80,6 +81,7 @@ export function TaxonomicFilter({schemaColumnsLoading,popoverEnabled,selectFirstItem,+ promoteSelectedItemToFirstPosition,excludedProperties,includeHiddenEvents,selectedProperties,diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.tsindex 65c99c7d6da0..ea196da37ef2 100644--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts@@ -1774,11 +1774,20 @@ describe('infiniteListLogic', () => {...props,})- it('floats the selected value above the group list when idle, without displacing a leading catch-all row', async () => {- logic = logicWith({ value: 'search term', groupType: TaxonomicFilterGroupType.Events })+ it.each([+ ['keeps the catch-all item first by default', undefined, ['All events', 'search term'], 'All events'],+ ['puts the selected series first when requested', true, ['search term', 'All events'], 'search term'],+ ])('%s', async (_description, promoteSelectedItemToFirstPosition, expectedNames, expectedSelectedName) => {+ logic = logicWith({+ value: 'search term',+ groupType: TaxonomicFilterGroupType.Events,+ promoteSelectedItemToFirstPosition,+ })await expectLogic(logic).toDispatchActions(['loadRemoteItemsSuccess'])- expect((logic.values.results[0] as { name?: string })?.name).toBe('All events')- expect((logic.values.results[1] as { name?: string })?.name).toBe('search term')+ expect(logic.values.results.slice(0, 2).map((item) => (item as { name?: string })?.name)).toEqual(+ expectedNames+ )+ expect((logic.values.selectedItem as { name?: string } | undefined)?.name).toBe(expectedSelectedName)})it('statically inserts the committed selection while its row is not yet loaded', async () => {diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.tsindex 176720e3d0be..7958e4dd6a04 100644--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts@@ -735,7 +735,8 @@ export interface infiniteListLogicMeta {groupType: TaxonomicFilterGroupType | undefinedvalue: TaxonomicFilterValue | undefined},- arg: boolean | undefined+ arg: boolean | undefined,+ arg2: boolean | undefined) => {count: numberfirst: boolean | undefined@@ -1778,6 +1779,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([s.taxonomicGroups,s.selectionPromotionContext,(_, props: InfiniteListLogicProps) => props.collapseUrlsToContainsRow,+ (_, props: InfiniteListLogicProps) => props.promoteSelectedItemToFirstPosition,],(remoteItems: ListStorage,@@ -1798,7 +1800,8 @@ export const infiniteListLogic = kea<infiniteListLogicType>([groupType: TaxonomicFilterGroupType | undefinedvalue: TaxonomicFilterValue | undefined},- collapseUrlsToContainsRow: boolean | undefined+ collapseUrlsToContainsRow: boolean | undefined,+ promoteSelectedItemToFirstPosition: boolean | undefined) => {const { group, groupType, value } = selectionPromotionContext// Collapse URL groups to a single "URL contains <query>" shortcut row@@ -1915,6 +1918,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([getItemGroup(leadingItem, taxonomicGroups, group)?.getValue?.(leadingItem) === null? 1: 0+ const selectedItemOffset = promoteSelectedItemToFirstPosition ? 0 : leadingCatchAllOffset// The synthetic stand-in for a selection whose real row isn't loaded —// shaped like a top match, so `getItemGroup` resolves its source group.// Only usable when the source group round-trips it back to the committed@@ -1933,7 +1937,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([} as unknown as TaxonomicDefinitionTypesconst syntheticRoundTrips = sourceGroup?.getValue?.(synthetic) === valueconst insertSynthetic = (list: typeof orderedBase): typeof orderedBase =>- leadingCatchAllOffset > 0 ? [list[0], synthetic, ...list.slice(1)] : [synthetic, ...list]+ selectedItemOffset > 0 ? [list[0], synthetic, ...list.slice(1)] : [synthetic, ...list]if (isSuggested) {// The aggregated list is fully client-side (recents/pinned prefixes),// so both floating and prepending are safe here.@@ -1951,7 +1955,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([)})if (selectedIndex >= 0) {- orderedBase = floatToFront(orderedBase, selectedIndex, leadingCatchAllOffset)+ orderedBase = floatToFront(orderedBase, selectedIndex, selectedItemOffset)} else if (syntheticRoundTrips) {orderedBase = insertSynthetic(orderedBase)syntheticSelectedCount = 1@@ -1987,8 +1991,8 @@ export const infiniteListLogic = kea<infiniteListLogicType>([}return true}- if (selectedIndex > leadingCatchAllOffset && rowsAboveSelectionLoaded()) {- orderedBase = floatToFront(orderedBase, selectedIndex, leadingCatchAllOffset)+ if (selectedIndex > selectedItemOffset && rowsAboveSelectionLoaded()) {+ orderedBase = floatToFront(orderedBase, selectedIndex, selectedItemOffset)}}}diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.tsindex 1914c15b5b07..a600a4dfd11a 100644--- a/frontend/src/lib/components/TaxonomicFilter/types.ts+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts@@ -139,6 +139,7 @@ export interface TaxonomicFilterProps {popoverEnabled?: booleanselectFirstItem?: booleanautoSelectItem?: boolean+ promoteSelectedItemToFirstPosition?: boolean/** use to filter results in a group by name, currently only working for EventProperties */excludedProperties?: ExcludedProperties/**diff --git a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsxindex ef0c7fc8dea4..a743989ded3d 100644--- a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx+++ b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx@@ -60,6 +60,7 @@ export interface TaxonomicPopoverProps<ValueType extends TaxonomicFilterValue =definitionPopoverRenderer?: DefinitionPopoverRenderersuggestedFiltersLabel?: stringenableKeywordShortcuts?: boolean+ promoteSelectedItemToFirstPosition?: booleanselectingKeyOnly?: boolean/** Called when the popover is opened. */onOpen?: () => void@@ -105,6 +106,7 @@ export const TaxonomicPopover = forwardRef(function TaxonomicPopover_<definitionPopoverRenderer,suggestedFiltersLabel,enableKeywordShortcuts,+ promoteSelectedItemToFirstPosition,selectingKeyOnly,onOpen,width,@@ -178,6 +180,7 @@ export const TaxonomicPopover = forwardRef(function TaxonomicPopover_<definitionPopoverRenderer={definitionPopoverRenderer}suggestedFiltersLabel={suggestedFiltersLabel}enableKeywordShortcuts={enableKeywordShortcuts}+ promoteSelectedItemToFirstPosition={promoteSelectedItemToFirstPosition}selectingKeyOnly={selectingKeyOnly}width={width}/>diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsxindex 39767cfab6ec..2b1e949c4561 100644--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx@@ -408,6 +408,7 @@ export function ActionFilterRow({filter={filter}suggestedFiltersLabel={suggestedFiltersLabel}enableKeywordShortcuts+ promoteSelectedItemToFirstPositionselectingKeyOnlyonChange={(changedValue, taxonomicGroupType, item) =>applyTaxonomicSelection(taxonomicGroupType, changedValue, item)