feat(surveys): fix dark theme + redesign closed survey error page#53813
feat(surveys): fix dark theme + redesign closed survey error page#53813lucasheriques wants to merge 1 commit intomasterfrom
Conversation
Graphite Automations"Add graphite merge queue" took an action on this PR • (04/09/26)2 labels were added to this PR based on Lucas Faria's automation. |
There was a problem hiding this comment.
UI/template-only redesign by the owning team author. The appearance data is safely injected via Django's json_script filter (XSS-safe) and the inline script carries a CSP nonce; CSS custom property injection via setProperty is constrained and cannot escalate to script execution. No data model, API contract, or backend logic changes of concern.
|
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
Query snapshots: Backend query snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
46ad403 to
4495f9e
Compare
Two real bugs on the hosted survey page surface (/external_surveys/<id>) plus a redesign of its error sibling: 1. renderSurvey() does NOT call addSurveyCSSVariablesToElement, so none of the --ph-survey-* container variables were being set by posthog-js on the API path. Customer appearance fields (inputBackground, borderColor, text colors, etc.) were silently ignored and dark-theme surveys kept black body text. Fix: replicate addSurveyCSSVariablesToElement locally in applyPageAppearance and set everything on :root so values cascade. 2. Corner branding pill was hardcoded to rgba(255,255,255,0.7), which reads as a glaring white badge on dark backgrounds. Now adapts to page luminance and flips to a dark translucent fill on dark themes. 3. surveys/error.html (shown when a survey is archived / not running / invalid) rewritten to match the hosted page's understated aesthetic. Drops the brand gradient stripe, logo, orange error circle, decorative dots, Go Back / Try Again buttons, and dark mode. Kept the template variables untouched. Threads survey.appearance through when we have the survey object loaded so a respondent hitting a closed survey link still sees the customer's brand (background, text color, font). Verified BREACH-safe changes — no reflected secrets, same @csrf_exempt view.
4495f9e to
a6b0072
Compare
Problem
Two real bugs on the hosted survey page + its error sibling looked wrong on dark themes.
Changes
renderSurvey()doesn't calladdSurveyCSSVariablesToElement— so none of the--ph-survey-*container variables were set by posthog-js on the API path. Customer appearance fields (`inputBackground`, `borderColor`, text colors, submit button colors, etc.) were silently ignored and dark-theme surveys kept black body text. Replicated the variable-setting logic locally in `applyPageAppearance` and set everything on `:root` so values cascade into the container.How did you test this code?
Authored by Claude in an interactive session with Lucas. Manually exercised on the dev server with a dark-theme customer survey (`backgroundColor: "#171717"`, explicit `textColor`, custom `inputBackground`). Verified that question text, inputs, buttons, borders, and the corner pill all respect the customer theme. Not tested on other browsers, real touch devices, or with screen readers.
Publish to changelog?
No
🤖 LLM context
The load-bearing finding: `posthog-js`'s `renderSurvey` at `surveys.tsx:377` only calls `Preact.render()` — it does not call `addSurveyCSSVariablesToElement`. That function is only wired into the automatic popup/widget display path. On the hosted survey page, every `var(--ph-survey-*, fallback)` in the template's CSS was silently resolving to the fallback, which is why customer appearance customization was being ignored for everything except `backgroundColor` (which we were already setting ourselves). The fix replicates `addSurveyCSSVariablesToElement`'s variable mapping locally. Fixing this upstream (have `renderSurvey` call the helper) would be a cleaner long-term path but affects every consumer of that API, so doing it here for now.