: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(surveys): add intro screen to the survey wizard (#116326)
Lucas Faria91ed8d5ad0db
diff --git a/frontend/src/scenes/surveys/SurveyFormAppearance.tsx b/frontend/src/scenes/surveys/SurveyFormAppearance.tsxindex 614c47f87016..ef7f6a31157a 100644--- a/frontend/src/scenes/surveys/SurveyFormAppearance.tsx+++ b/frontend/src/scenes/surveys/SurveyFormAppearance.tsx@@ -7,11 +7,11 @@ import { surveysLogic } from 'scenes/surveys/surveysLogic'import { Survey, SurveyType } from '~/types'-import { INTRO_SCREEN_PAGE_INDEX, NewSurvey } from './constants'+import { NewSurvey } from './constants'import { SurveyAPIEditor } from './SurveyAPIEditor'import { SurveyAppearancePreview } from './SurveyAppearancePreview'import { getNextPreviewPageIndex } from './surveyPreviewNavigation'-import { clampPreviewPageIndex, getIntroScreenPageOptions } from './utils'+import { clampPreviewPageIndex, getFirstPreviewPageIndex, getIntroScreenPageOptions } from './utils'interface SurveyFormAppearanceProps {previewPageIndex: number@@ -44,12 +44,7 @@ export function SurveyFormAppearance({}}}onPreviewBack={() =>- handleSetSelectedPageIndex(- Math.max(- survey.appearance?.displayIntroScreen ? INTRO_SCREEN_PAGE_INDEX : 0,- effectivePageIndex - 1- )- )+ handleSetSelectedPageIndex(Math.max(getFirstPreviewPageIndex(survey), effectivePageIndex - 1))}/><LemonField.Pure label="Current question" className="max-w-xs gap-1" htmlFor="current-question-select">diff --git a/frontend/src/scenes/surveys/utils.ts b/frontend/src/scenes/surveys/utils.tsindex 4111984e882d..817350982d14 100644--- a/frontend/src/scenes/surveys/utils.ts+++ b/frontend/src/scenes/surveys/utils.ts@@ -296,6 +296,10 @@ export function clampPreviewPageIndex(return index}+export function getFirstPreviewPageIndex(survey: Pick<Survey | NewSurvey, 'appearance'>): number {+ return survey.appearance?.displayIntroScreen ? INTRO_SCREEN_PAGE_INDEX : 0+}+export function getIntroScreenPageOptions(survey: Pick<Survey | NewSurvey, 'appearance'>): { label: string; value: number }[] {diff --git a/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx b/frontend/src/scenes/surveys/wizard/SurveyWizard.tsxindex fd13ceb6f73c..86e52165ea43 100644--- a/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx+++ b/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx@@ -1,7 +1,6 @@import clsx from 'clsx'import { BindLogic, useActions, useValues } from 'kea'import { router } from 'kea-router'-import { getNextSurveyStep } from 'posthog-js/dist/surveys-preview'import { useEffect, useState } from 'react'import { IconArrowLeft, IconChevronLeft, IconChevronRight } from '@posthog/icons'@@ -17,19 +16,25 @@ import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { themeLogic } from '~/layout/navigation-3000/themeLogic'-import { SurveyMatchType, SurveyQuestionBranchingType, SurveyType } from '~/types'+import { SurveyMatchType, SurveyType } from '~/types'import { HostedSurveyRespondentHint } from '../components/HostedSurveyRespondentHint'import { SdkVersionWarnings } from '../components/SdkVersionWarnings'import { SurveyPublicContentNotice } from '../components/SurveyPublicContentNotice'import { SurveysDisabledLaunchWarning } from '../components/SurveysDisabledLaunchWarning'-import { NewSurvey } from '../constants'+import { INTRO_SCREEN_PAGE_INDEX, NewSurvey } from '../constants'import { SurveyAppearancePreview } from '../SurveyAppearancePreview'import { getEventPropertyFilterCount } from '../SurveyEventTrigger'import { surveyLogic } from '../surveyLogic'+import { getNextPreviewPageIndex } from '../surveyPreviewNavigation'import { surveysLogic } from '../surveysLogic'import { getSurveyWithTranslatedContent } from '../surveyTranslationUtils'-import { canUseSurveyWizard, doesSurveyHaveDisplayConditions, getSurveyAudienceSummaryValue } from '../utils'+import {+ canUseSurveyWizard,+ doesSurveyHaveDisplayConditions,+ getFirstPreviewPageIndex,+ getSurveyAudienceSummaryValue,+} from '../utils'import { MaxTip } from './MaxTip'import { AppearanceStep } from './steps/AppearanceStep'import { QuestionsStep } from './steps/QuestionsStep'@@ -115,13 +120,16 @@ function SurveyWizard({ id }: SurveyWizardLogicProps): JSX.Element {const [guidedEditingLanguage, setGuidedEditingLanguage] = useState<string | null>(null)const activeEditingLanguage = surveyTranslationsEnabled ? guidedEditingLanguage : null+ const minPreviewIndex = getFirstPreviewPageIndex(survey)const maxPreviewIndex = survey.appearance?.displayThankYouMessage? survey.questions.length: survey.questions.length - 1useEffect(() => {- setPreviewPageIndex((current) => (current > maxPreviewIndex ? Math.max(0, maxPreviewIndex) : current))- }, [maxPreviewIndex])+ setPreviewPageIndex((current) =>+ Math.min(Math.max(current, minPreviewIndex), Math.max(minPreviewIndex, maxPreviewIndex))+ )+ }, [minPreviewIndex, maxPreviewIndex])useEffect(() => {if (!surveyTranslationsEnabled && guidedEditingLanguage !== null) {@@ -435,6 +443,7 @@ function SurveyWizard({ id }: SurveyWizardLogicProps): JSX.Element {<QuestionsStepeditingLanguage={guidedEditingLanguage}setEditingLanguage={setGuidedEditingLanguage}+ onIntroScreenEnabled={() => setPreviewPageIndex(INTRO_SCREEN_PAGE_INDEX)}/>)}{currentStep === 'where' && <WhereStep onOpenFullEditor={handleCustomizeMore} />}@@ -498,33 +507,34 @@ function SurveyWizard({ id }: SurveyWizardLogicProps): JSX.Element {survey={previewSurvey}previewPageIndex={previewPageIndex}onPreviewSubmit={(response) => {- const next = getNextSurveyStep(previewSurvey, previewPageIndex, response)- if (- next === SurveyQuestionBranchingType.End &&- !previewSurvey.appearance?.displayThankYouMessage- ) {- return- }- setPreviewPageIndex(- next === SurveyQuestionBranchingType.End- ? previewSurvey.questions.length- : next+ const nextPageIndex = getNextPreviewPageIndex(+ previewSurvey,+ previewPageIndex,+ response)+ if (nextPageIndex !== null) {+ setPreviewPageIndex(nextPageIndex)+ }}}/></div>{(previewSurvey.questions.length > 1 ||- previewSurvey.appearance?.displayThankYouMessage) && (+ previewSurvey.appearance?.displayThankYouMessage ||+ previewSurvey.appearance?.displayIntroScreen) && (<div className="flex items-center justify-center gap-2 mt-2"><LemonButtontype="secondary"size="small"icon={<IconChevronLeft />}- onClick={() => setPreviewPageIndex(Math.max(0, previewPageIndex - 1))}- disabledReason={previewPageIndex === 0 ? 'First question' : undefined}+ onClick={() =>+ setPreviewPageIndex(Math.max(minPreviewIndex, previewPageIndex - 1))+ }+ disabledReason={+ previewPageIndex <= minPreviewIndex ? 'First screen' : undefined+ }/><span className="text-muted text-xs min-w-[60px] text-center">- {`${previewPageIndex + 1} / ${maxPreviewIndex + 1}`}+ {`${previewPageIndex - minPreviewIndex + 1} / ${maxPreviewIndex - minPreviewIndex + 1}`}</span><LemonButtontype="secondary"diff --git a/frontend/src/scenes/surveys/wizard/steps/AppearanceStep.tsx b/frontend/src/scenes/surveys/wizard/steps/AppearanceStep.tsxindex bebb722b1ed3..74911258999f 100644--- a/frontend/src/scenes/surveys/wizard/steps/AppearanceStep.tsx+++ b/frontend/src/scenes/surveys/wizard/steps/AppearanceStep.tsx@@ -1,6 +1,5 @@import clsx from 'clsx'import { useActions, useValues } from 'kea'-import { getNextSurveyStep } from 'posthog-js/dist/surveys-preview'import { useState } from 'react'import { IconChevronLeft, IconChevronRight } from '@posthog/icons'@@ -13,15 +12,10 @@ import { LemonCollapse } from 'lib/lemon-ui/LemonCollapse'import { LemonField } from 'lib/lemon-ui/LemonField'import { themeLogic } from '~/layout/navigation-3000/themeLogic'-import {- AvailableFeature,- SurveyAppearance,- SurveyPosition,- SurveyQuestionBranchingType,- SurveyQuestionType,-} from '~/types'+import { AvailableFeature, SurveyAppearance, SurveyPosition, SurveyQuestionType } from '~/types'import {+ INTRO_SCREEN_PAGE_INDEX,NewSurvey,SurveyTheme,WEB_SAFE_FONTS,@@ -31,7 +25,9 @@ import {import { SurveyBehaviorOptions } from '../../survey-appearance/SurveyBehaviorOptions'import { SurveyAppearancePreview } from '../../SurveyAppearancePreview'import { surveyLogic } from '../../surveyLogic'+import { getNextPreviewPageIndex } from '../../surveyPreviewNavigation'import { surveysLogic } from '../../surveysLogic'+import { getFirstPreviewPageIndex } from '../../utils'import { ColorInput } from '../ColorInput'import { SurveyThemeSelector } from '../SurveyThemeSelector'@@ -73,6 +69,7 @@ export function AppearanceStep(): JSX.Element {} as NewSurveyconst totalPreviewPages = survey.questions.length + (appearance.displayThankYouMessage ? 1 : 0)+ const minPreviewIndex = getFirstPreviewPageIndex(survey)return (<div className="grid grid-cols-1 gap-5 lg:grid-cols-3">@@ -272,31 +269,30 @@ export function AppearanceStep(): JSX.Element {survey={previewSurvey}previewPageIndex={previewPageIndex}onPreviewSubmit={(response) => {- const next = getNextSurveyStep(previewSurvey, previewPageIndex, response)- if (next === SurveyQuestionBranchingType.End && !appearance.displayThankYouMessage) {- return+ const nextPageIndex = getNextPreviewPageIndex(previewSurvey, previewPageIndex, response)+ if (nextPageIndex !== null) {+ setPreviewPageIndex(nextPageIndex)}- setPreviewPageIndex(- next === SurveyQuestionBranchingType.End ? survey.questions.length : next- )}}/></div>{/* Preview navigation */}- {totalPreviewPages > 1 && (+ {(totalPreviewPages > 1 || appearance.displayIntroScreen) && (<div className="flex items-center justify-center gap-2"><LemonButtontype="secondary"size="small"icon={<IconChevronLeft />}- onClick={() => setPreviewPageIndex(Math.max(0, previewPageIndex - 1))}- disabledReason={previewPageIndex === 0 ? 'First question' : undefined}+ onClick={() => setPreviewPageIndex(Math.max(minPreviewIndex, previewPageIndex - 1))}+ disabledReason={previewPageIndex <= minPreviewIndex ? 'First screen' : undefined}/><span className="text-muted text-sm min-w-[80px] text-center">- {previewPageIndex < survey.questions.length- ? `${previewPageIndex + 1} of ${survey.questions.length}`- : 'Thank you'}+ {previewPageIndex === INTRO_SCREEN_PAGE_INDEX+ ? 'Intro'+ : previewPageIndex < survey.questions.length+ ? `${previewPageIndex + 1} of ${survey.questions.length}`+ : 'Thank you'}</span><LemonButtontype="secondary"diff --git a/frontend/src/scenes/surveys/wizard/steps/IntroScreenEditor.test.tsx b/frontend/src/scenes/surveys/wizard/steps/IntroScreenEditor.test.tsxnew file mode 100644index 000000000000..4d517acf3013--- /dev/null+++ b/frontend/src/scenes/surveys/wizard/steps/IntroScreenEditor.test.tsx@@ -0,0 +1,65 @@+import '@testing-library/jest-dom'++import { cleanup, fireEvent, render, screen } from '@testing-library/react'++import { initKeaTests } from '~/test/init'+import { SurveyAppearance } from '~/types'++import { IntroScreenEditor } from './IntroScreenEditor'++describe('IntroScreenEditor', () => {+ beforeEach(() => {+ initKeaTests()+ })++ afterEach(() => {+ cleanup()+ })++ it.each([+ ['an enabled intro with no content', { displayIntroScreen: true }, true],+ ['an enabled intro with a header', { displayIntroScreen: true, introScreenHeader: 'Welcome' }, false],+ ['an enabled intro with a description', { displayIntroScreen: true, introScreenDescription: 'Hi' }, false],+ ['a disabled intro', { displayIntroScreen: false }, false],+ ] as [string, SurveyAppearance, boolean][])(+ 'warns that the intro will not show for %s',+ (_name, appearance, warns) => {+ render(<IntroScreenEditor appearance={appearance} onUpdate={jest.fn()} onToggle={jest.fn()} />)++ const warning = screen.queryByText("The intro screen won't show until it has a header or a description.")+ expect(!!warning).toBe(warns)+ }+ )++ it.each([+ ['an unset content type', undefined, 'html'],+ ['an html content type', 'html', 'html'],+ ['a text content type', 'text', 'text'],+ ] as const)('opens the description on the tab the SDK renders for %s', (_name, contentType, expectedTab) => {+ render(+ <IntroScreenEditor+ appearance={{ displayIntroScreen: true, introScreenDescriptionContentType: contentType }}+ onUpdate={jest.fn()}+ onToggle={jest.fn()}+ />+ )++ const activeTab = expectedTab === 'html' ? 'HTML' : 'Text'+ expect(screen.getByText(activeTab).closest('[role="tab"]')).toHaveAttribute('aria-selected', 'true')+ })++ it('lets an html intro switch its description to text', () => {+ const onUpdate = jest.fn()+ render(+ <IntroScreenEditor+ appearance={{ displayIntroScreen: true, introScreenDescriptionContentType: 'html' }}+ onUpdate={onUpdate}+ onToggle={jest.fn()}+ />+ )++ fireEvent.click(screen.getByText('Text'))++ expect(onUpdate).toHaveBeenCalledWith({ introScreenDescriptionContentType: 'text' })+ })+})diff --git a/frontend/src/scenes/surveys/wizard/steps/IntroScreenEditor.tsx b/frontend/src/scenes/surveys/wizard/steps/IntroScreenEditor.tsxnew file mode 100644index 000000000000..4719e7cb2dcb--- /dev/null+++ b/frontend/src/scenes/surveys/wizard/steps/IntroScreenEditor.tsx@@ -0,0 +1,56 @@+import { LemonBanner } from '@posthog/lemon-ui'++import { EditableField } from 'lib/components/EditableField/EditableField'++import { SurveyAppearance } from '~/types'++import { HTMLEditor } from '../../SurveyAppearanceUtils'+import { getIntroScreenDescriptionContentType, isIntroScreenShown } from '../../surveyIntroScreen'+import { ScreenEditorCard } from './ScreenEditorCard'++interface IntroScreenEditorProps {+ appearance: SurveyAppearance+ onUpdate: (updates: Partial<SurveyAppearance>) => void+ onToggle: (enabled: boolean) => void+}++export function IntroScreenEditor({ appearance, onUpdate, onToggle }: IntroScreenEditorProps): JSX.Element {+ return (+ <ScreenEditorCard title="Intro screen" enabled={appearance.displayIntroScreen ?? false} onToggle={onToggle}>+ {!isIntroScreenShown(appearance) && (+ <LemonBanner type="warning">+ The intro screen won't show until it has a header or a description.+ </LemonBanner>+ )}+ <EditableField+ name="intro-header"+ value={appearance.introScreenHeader || ''}+ onSave={(text) => onUpdate({ introScreenHeader: text })}+ placeholder="Help us improve"+ className="font-medium text-sm"+ saveOnBlur+ clickToEdit+ compactIcon+ showEditIconOnHover+ />+ <HTMLEditor+ value={appearance.introScreenDescription || ''}+ onChange={(text) => onUpdate({ introScreenDescription: text })}+ activeTab={getIntroScreenDescriptionContentType(appearance)}+ onTabChange={(contentType) => onUpdate({ introScreenDescriptionContentType: contentType })}+ textPlaceholder="Add a description (optional)"+ />+ <EditableField+ name="intro-button-text"+ value={appearance.introScreenButtonText || ''}+ onSave={(text) => onUpdate({ introScreenButtonText: text })}+ placeholder="Get started"+ className="text-secondary text-xs"+ saveOnBlur+ clickToEdit+ compactIcon+ showEditIconOnHover+ />+ </ScreenEditorCard>+ )+}diff --git a/frontend/src/scenes/surveys/wizard/steps/QuestionsStep.tsx b/frontend/src/scenes/surveys/wizard/steps/QuestionsStep.tsxindex 64193bdfd1d1..b374303d1eb7 100644--- a/frontend/src/scenes/surveys/wizard/steps/QuestionsStep.tsx+++ b/frontend/src/scenes/surveys/wizard/steps/QuestionsStep.tsx@@ -2,12 +2,11 @@ import { DndContext, DragEndEvent, DragOverlay, DragStartEvent } from '@dnd-kit/import { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'import { CSS } from '@dnd-kit/utilities'import { useActions, useValues } from 'kea'-import { AnimatePresence, motion } from 'motion/react'import { useState } from 'react'import { createPortal } from 'react-dom'import { IconEmoji, IconPlusSmall, IconRevert, IconTrash } from '@posthog/icons'-import { LemonButton, LemonCheckbox, LemonInput, LemonSegmentedButton, LemonSwitch, LemonTag } from '@posthog/lemon-ui'+import { LemonButton, LemonCheckbox, LemonInput, LemonSegmentedButton, LemonTag } from '@posthog/lemon-ui'import { EditableField } from 'lib/components/EditableField/EditableField'import { GuidedWizardSection } from 'lib/components/GuidedWizard/GuidedWizardSection'@@ -29,10 +28,12 @@ import {import { SCALE_OPTIONS, SURVEY_RATING_SCALE, defaultSurveyAppearance, defaultSurveyFieldValues } from '../../constants'import { HTMLEditor } from '../../SurveyAppearanceUtils'import { surveyLogic } from '../../surveyLogic'-import { splitChoicesOnPaste } from '../../utils'+import { splitChoicesOnPaste, withIntroScreenEnabled } from '../../utils'import { AddQuestionButton } from '../AddQuestionButton'import { QuestionTypeChip } from '../QuestionTypeChip'import { surveyWizardLogic } from '../surveyWizardLogic'+import { IntroScreenEditor } from './IntroScreenEditor'+import { ScreenEditorCard } from './ScreenEditorCard'import { TranslationsSection } from './TranslationsSection'const MAX_CHOICES = 10@@ -326,56 +327,36 @@ interface ConfirmationScreenEditorProps {}function ConfirmationScreenEditor({ appearance, onUpdate }: ConfirmationScreenEditorProps): JSX.Element {- const isEnabled = appearance.displayThankYouMessage ?? true-return (- <div className="border border-border rounded-lg bg-bg-light overflow-hidden">- {/* Always visible header with toggle */}- <div className="flex items-center justify-between gap-2 px-3 py-2.5">- <span className="text-sm font-medium">Confirmation screen</span>- <LemonSwitch- checked={isEnabled}- onChange={(checked) => onUpdate({ displayThankYouMessage: checked })}- />- </div>-- {/* Animated expandable content */}- <AnimatePresence initial={false}>- {isEnabled && (- <motion.div- initial={{ height: 0, opacity: 0 }}- animate={{ height: 'auto', opacity: 1 }}- exit={{ height: 0, opacity: 0 }}- transition={{ duration: 0.2, ease: [0.25, 1, 0.5, 1] }}- >- <div className="px-3 pb-3 space-y-2 border-t border-border pt-2.5">- <EditableField- name="confirmation-header"- value={appearance.thankYouMessageHeader || ''}- onSave={(text) => onUpdate({ thankYouMessageHeader: text })}- placeholder="Thank you for your feedback!"- className="font-medium text-sm"- saveOnBlur- clickToEdit- compactIcon- showEditIconOnHover- />- <EditableField- name="confirmation-description"- value={appearance.thankYouMessageDescription || ''}- onSave={(text) => onUpdate({ thankYouMessageDescription: text })}- placeholder="Add a description (optional)"- className="text-secondary text-xs"- saveOnBlur- clickToEdit- compactIcon- showEditIconOnHover- />- </div>- </motion.div>- )}- </AnimatePresence>- </div>+ <ScreenEditorCard+ title="Confirmation screen"+ enabled={appearance.displayThankYouMessage ?? true}+ onToggle={(checked) => onUpdate({ displayThankYouMessage: checked })}+ >+ <EditableField+ name="confirmation-header"+ value={appearance.thankYouMessageHeader || ''}+ onSave={(text) => onUpdate({ thankYouMessageHeader: text })}+ placeholder="Thank you for your feedback!"+ className="font-medium text-sm"+ saveOnBlur+ clickToEdit+ compactIcon+ showEditIconOnHover+ />+ <EditableField+ name="confirmation-description"+ multiline+ value={appearance.thankYouMessageDescription || ''}+ onSave={(text) => onUpdate({ thankYouMessageDescription: text })}+ placeholder="Add a description (optional)"+ className="text-secondary text-xs"+ saveOnBlur+ clickToEdit+ compactIcon+ showEditIconOnHover+ />+ </ScreenEditorCard>)}@@ -513,9 +494,14 @@ function SortableQuestionCard({interface QuestionsStepProps {editingLanguage: string | nullsetEditingLanguage: (language: string | null) => void+ onIntroScreenEnabled: () => void}-export function QuestionsStep({ editingLanguage, setEditingLanguage }: QuestionsStepProps): JSX.Element {+export function QuestionsStep({+ editingLanguage,+ setEditingLanguage,+ onIntroScreenEnabled,+}: QuestionsStepProps): JSX.Element {const { survey } = useValues(surveyLogic)const { setSurveyValue, moveQuestion, removeQuestion } = useActions(surveyLogic)const { selectedTemplate } = useValues(surveyWizardLogic)@@ -602,6 +588,19 @@ export function QuestionsStep({ editingLanguage, setEditingLanguage }: Questions) : null}/>+ <IntroScreenEditor+ appearance={{ ...defaultSurveyAppearance, ...survey.appearance }}+ onUpdate={(updates) => setSurveyValue('appearance', { ...survey.appearance, ...updates })}+ onToggle={(enabled) => {+ if (enabled) {+ setSurveyValue('appearance', withIntroScreenEnabled(survey.appearance))+ onIntroScreenEnabled()+ } else {+ setSurveyValue('appearance', { ...survey.appearance, displayIntroScreen: false })+ }+ }}+ />+<DndContext onDragStart={handleDragStart} onDragEnd={handleDragEnd}><SortableContext items={sortedItemIds} strategy={verticalListSortingStrategy} disabled={!canReorder}><div className="space-y-3">diff --git a/frontend/src/scenes/surveys/wizard/steps/ScreenEditorCard.test.tsx b/frontend/src/scenes/surveys/wizard/steps/ScreenEditorCard.test.tsxnew file mode 100644index 000000000000..05d9ee049dc1--- /dev/null+++ b/frontend/src/scenes/surveys/wizard/steps/ScreenEditorCard.test.tsx@@ -0,0 +1,21 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'++import { ScreenEditorCard } from './ScreenEditorCard'++describe('ScreenEditorCard', () => {+ afterEach(() => {+ cleanup()+ })++ it.each(['Intro screen', 'Confirmation screen'])('names the %s toggle after the card', (title) => {+ render(+ <ScreenEditorCard title={title} enabled={false} onToggle={jest.fn()}>+ <span />+ </ScreenEditorCard>+ )++ expect(screen.getByLabelText(title)).toHaveAttribute('role', 'switch')+ })+})diff --git a/frontend/src/scenes/surveys/wizard/steps/ScreenEditorCard.tsx b/frontend/src/scenes/surveys/wizard/steps/ScreenEditorCard.tsxnew file mode 100644index 000000000000..4dab76edecab--- /dev/null+++ b/frontend/src/scenes/surveys/wizard/steps/ScreenEditorCard.tsx@@ -0,0 +1,36 @@+import { AnimatePresence, motion } from 'motion/react'++import { LemonSwitch } from '@posthog/lemon-ui'++interface ScreenEditorCardProps {+ title: string+ enabled: boolean+ onToggle: (enabled: boolean) => void+ children: React.ReactNode+}++export function ScreenEditorCard({ title, enabled, onToggle, children }: ScreenEditorCardProps): JSX.Element {+ return (+ <div className="border border-border rounded-lg bg-bg-light overflow-hidden">+ {/* Always visible header with toggle */}+ <div className="flex items-center justify-between gap-2 px-3 py-2.5">+ <span className="text-sm font-medium">{title}</span>+ <LemonSwitch checked={enabled} onChange={onToggle} aria-label={title} />+ </div>++ {/* Animated expandable content */}+ <AnimatePresence initial={false}>+ {enabled && (+ <motion.div+ initial={{ height: 0, opacity: 0 }}+ animate={{ height: 'auto', opacity: 1 }}+ exit={{ height: 0, opacity: 0 }}+ transition={{ duration: 0.2, ease: [0.25, 1, 0.5, 1] }}+ >+ <div className="px-3 pb-3 space-y-2 border-t border-border pt-2.5">{children}</div>+ </motion.div>+ )}+ </AnimatePresence>+ </div>+ )+}diff --git a/frontend/src/scenes/surveys/wizard/surveyWizardLogic.test.ts b/frontend/src/scenes/surveys/wizard/surveyWizardLogic.test.tsindex 542bc779705b..a951ecd26a0b 100644--- a/frontend/src/scenes/surveys/wizard/surveyWizardLogic.test.ts+++ b/frontend/src/scenes/surveys/wizard/surveyWizardLogic.test.ts@@ -349,6 +349,24 @@ describe('surveyWizardLogic', () => {})})+ it('should carry every intro screen field from the template appearance', async () => {+ const logic = surveyWizardLogic({ id: 'new' })+ logic.mount()+ const introScreenAppearance = {+ displayIntroScreen: true,+ introScreenHeader: 'Help us improve',+ introScreenDescription: '<b>One minute</b>',+ introScreenDescriptionContentType: 'html' as const,+ introScreenButtonText: 'Start',+ }++ await expectLogic(logic, () => {+ logic.actions.selectTemplate({ ...createMockTemplate(), appearance: introScreenAppearance })+ }).toMatchValues({+ survey: expect.objectContaining({ appearance: expect.objectContaining(introScreenAppearance) }),+ })+ })+it('should apply recommended frequency based on template type', async () => {const logic = surveyWizardLogic({ id: 'new' })logic.mount()diff --git a/frontend/src/scenes/surveys/wizard/surveyWizardLogic.ts b/frontend/src/scenes/surveys/wizard/surveyWizardLogic.tsindex 2f7c9af5a723..7bcf1851b4f3 100644--- a/frontend/src/scenes/surveys/wizard/surveyWizardLogic.ts+++ b/frontend/src/scenes/surveys/wizard/surveyWizardLogic.ts@@ -449,6 +449,11 @@ export const surveyWizardLogic = kea<surveyWizardLogicType>([? {displayThankYouMessage: template.appearance.displayThankYouMessage,thankYouMessageHeader: template.appearance.thankYouMessageHeader,+ displayIntroScreen: template.appearance.displayIntroScreen,+ introScreenHeader: template.appearance.introScreenHeader,+ introScreenDescription: template.appearance.introScreenDescription,+ introScreenDescriptionContentType: template.appearance.introScreenDescriptionContentType,+ introScreenButtonText: template.appearance.introScreenButtonText,position: template.appearance.position,shuffleQuestions: template.appearance.shuffleQuestions,surveyPopupDelaySeconds: template.appearance.surveyPopupDelaySeconds,