: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
feat(scenes): add search to default dashboard picker in configure home modal (#68527)
Paul D'Ambrad201cc7dee96
diff --git a/frontend/src/layout/scenes/ConfigureHomeModal.tsx b/frontend/src/layout/scenes/ConfigureHomeModal.tsxindex 7f97413ecb33..6523914bca13 100644--- a/frontend/src/layout/scenes/ConfigureHomeModal.tsx+++ b/frontend/src/layout/scenes/ConfigureHomeModal.tsx@@ -2,7 +2,7 @@ import { useActions, useValues } from 'kea'import posthog from 'posthog-js'import { useEffect, useState } from 'react'-import { LemonSegmentedButton, LemonSelect, LemonSelectOptions, LemonTag } from '@posthog/lemon-ui'+import { LemonSearchableSelect, LemonSegmentedButton, LemonSelectOptions, LemonTag } from '@posthog/lemon-ui'import { LemonModal } from 'lib/lemon-ui/LemonModal'@@ -175,11 +175,13 @@ export function ConfigureHomeModal({ isOpen, onClose }: ConfigureHomeModalProps)This dashboard opens by default for everyone who has not set a custom homepage.</p></div>- <LemonSelect<number | null>+ <LemonSearchableSelect<number | null>className="w-full"fullWidthoptions={projectDefaultDashboardOptions}value={projectDefaultDashboardId}+ searchPlaceholder="Search dashboards…"+ searchInputDataAttr="configure-home-modal-default-dashboard-search"data-attr="configure-home-modal-set-default-dashboard-select"onChange={(dashboardId) => {posthog.capture('homepage configure default dashboard changed')diff --git a/frontend/src/lib/lemon-ui/LemonSelect/LemonSearchableSelect.tsx b/frontend/src/lib/lemon-ui/LemonSelect/LemonSearchableSelect.tsxindex 3f7d7dae8a81..9468e65e0b33 100644--- a/frontend/src/lib/lemon-ui/LemonSelect/LemonSearchableSelect.tsx+++ b/frontend/src/lib/lemon-ui/LemonSelect/LemonSearchableSelect.tsx@@ -18,6 +18,8 @@ import {export interface LemonSearchableSelectPropsBase<T> extends LemonSelectPropsBase<T> {searchPlaceholder?: stringsearchKeys?: string[]+ /** `data-attr` for the search input, so its usage can be tracked per call site. */+ searchInputDataAttr?: string}export interface LemonSearchableSelectPropsClearable<T>@@ -89,6 +91,7 @@ function filterOptions<T>(export function LemonSearchableSelect<T extends string | number | boolean | null>({searchPlaceholder,searchKeys = ['label'],+ searchInputDataAttr = 'lemon-searchable-select-search',onChange,onSelect,...selectProps@@ -112,13 +115,14 @@ export function LemonSearchableSelect<T extends string | number | boolean | nullfullWidthonClick={(e) => e.stopPropagation()}className="mb-1"+ data-attr={searchInputDataAttr}/>),custom: true,} as anyreturn [searchMenuItem, ...filteredOptions] as LemonSelectOptions<T>- }, [searchPlaceholder, searchTerm, filteredOptions])+ }, [searchPlaceholder, searchTerm, filteredOptions, searchInputDataAttr])const handleChange = (newValue: T | null): void => {// Cast to `any` because `onChange` is a union type (T vs T | null) and TS can't infer it here.@@ -132,6 +136,22 @@ export function LemonSearchableSelect<T extends string | number | boolean | null}return (- <LemonSelect {...selectProps} options={optionsWithSearch} onChange={handleChange} onSelect={handleOnSelect} />+ <LemonSelect+ {...selectProps}+ options={optionsWithSearch}+ onChange={handleChange}+ onSelect={handleOnSelect}+ menu={{+ ...selectProps.menu,+ onVisibilityChange: (visible) => {+ selectProps.menu?.onVisibilityChange?.(visible)+ // Clear the filter when the dropdown closes, otherwise a stale search term keeps the+ // selected option filtered out and the trigger falls back to rendering the raw value.+ if (!visible) {+ setSearchTerm('')+ }+ },+ }}+ />)}diff --git a/frontend/src/lib/lemon-ui/LemonSelect/LemonSelect.tsx b/frontend/src/lib/lemon-ui/LemonSelect/LemonSelect.tsxindex 160db3730885..533bf2be5672 100644--- a/frontend/src/lib/lemon-ui/LemonSelect/LemonSelect.tsx+++ b/frontend/src/lib/lemon-ui/LemonSelect/LemonSelect.tsx@@ -79,7 +79,7 @@ export interface LemonSelectPropsBase<T> extends Pick<className?: stringplaceholder?: stringsize?: LemonButtonProps['size']- menu?: Pick<LemonMenuProps, 'className' | 'closeParentPopoverOnClickInside'>+ menu?: Pick<LemonMenuProps, 'className' | 'closeParentPopoverOnClickInside' | 'onVisibilityChange'>visible?: LemonDropdownProps['visible']startVisible?: LemonDropdownProps['startVisible']truncateText?: { maxWidthClass: string }@@ -150,6 +150,7 @@ export function LemonSelect<T extends string | number | boolean | null>({.flatMap((i) => (isLemonMenuSection(i) ? i.items.filter(Boolean) : i)).findIndex((i) => (i as LemonMenuItem).active)}closeParentPopoverOnClickInside={menu?.closeParentPopoverOnClickInside}+ onVisibilityChange={menu?.onVisibilityChange}visible={visible}startVisible={startVisible}>