Skip to content

feat: forward appearance and setAppearance() to the SDK for dark mode - #59

Merged
Dhruwang merged 1 commit into
mainfrom
feat/appearance
Oct 19, 2026
Merged

Dhruwang merged 1 commit into
mainfrom
feat/appearance

Conversation

@Dhruwang

@Dhruwang Dhruwang commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

What & why

Was: @formbricks/js had no way to turn on dark mode. setup({ appearance }) dropped the field, and formbricks.setAppearance was undefined, although the SDK the wrapper loads supports both since Formbricks 6.1 (formbricks/formbricks#9549).

Now: both are forwarded and typed (TAppearance is exported), and the version is 5.2.0 so a release can go out with Formbricks 6.1. Custom CSS needs no wrapper change: it comes from the server.

  • setAppearance() before the SDK script loads is applied right after load and before setup(), matching js-core, which applies appearance outside its queue. Queuing it behind setup would show a survey triggered during setup in light first.
  • On a server older than 6.1, setAppearance() logs the existing "Method … does not exist" error, and appearance in setup() is ignored (6.0 only reads the fields it knows).

Where to look

  • packages/js/src/lib/load-formbricks.ts: setAppearance, applyPendingAppearanceTo, and appearance passthrough in validateSetupArgs
  • packages/js/src/types/formbricks.ts: TAppearance, setAppearance, TSetupConfig.appearance

Coverage

Behaviour Level Test
appearance in setup() reaches the SDK unit (mutation) load-formbricks.test.ts › should forward appearance from the setup config to the SDK. Red without ...appearanceArg in validateSetupArgs
early setAppearance runs before SDK setup() unit (mutation) › should apply a setAppearance made before load ahead of setup. Red without the applyPendingAppearanceTo(instance) call
after setup, goes straight to the SDK unit (guard) › should call the SDK directly once setup has run
older SDK logs instead of throwing unit (mutation) › should log instead of throwing when the SDK predates setAppearance
wrapper delegates to the loader unit (guard) index.test.ts › should delegate setAppearance to the loader's setAppearance
end to end against a 6.1 instance manual Built package on a test page against staging (6.1.0-rc.2): setAppearance("dark") before setup opens the survey dark; setAppearance("light") switches the open survey in place; setup({ appearance: "dark" }) opens it dark

Rerun: pnpm --filter @formbricks/js test

Open gaps

  • "system" not checked against a dark OS setting in a real browser.

Affected packages: packages/js (plus a "Dark mode" section in both READMEs).

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 80f3ccf2-c73b-4e95-b2e3-399f3f17ece1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@Dhruwang
Dhruwang requested a review from pandeymangg October 19, 2026 12:27
@Dhruwang
Dhruwang added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 4dd0431 Oct 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants