Skip to content

Synchronize document.body theme classes and attributes in PreviewBridge - #150

Merged
jgindin merged 2 commits into
mainfrom
fix-dark-light-mode
Aug 5, 2026
Merged

jgindin merged 2 commits into
mainfrom
fix-dark-light-mode

Conversation

@jgindin

@jgindin jgindin commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Updates PreviewBridge.applyThemeToDom and attachRenderer to apply the dark-theme CSS class, color-scheme CSS style, and data-theme attribute to document.body in addition to document.documentElement. This ensures proper theme propagation in frameworks and renderers where dark mode styling rules target document.body.

This fix was suggested to help with renderer apps that may be looking for dark/light mode CSS on the body.

Pre-launch Checklist

  • I signed the [CLA].
  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • I have added updates to the [CHANGELOG].
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on fork, I have verified that scripts/e2e_test.sh passes.

Updates PreviewBridge.applyThemeToDom and attachRenderer to apply the
dark-theme CSS class, color-scheme CSS style, and data-theme attribute
to document.body in addition to document.documentElement. This ensures
proper theme propagation in frameworks and renderers where dark mode
styling rules target document.body.

TAG=agy
CONV=13dfcb37-0b15-42e8-a26b-0c91b22c4741

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PreviewBridge to apply theme styles and attributes (such as the .dark-theme class, color-scheme style, and data-theme attribute) to document.body in addition to document.documentElement. It also adds corresponding unit tests to verify this behavior. The feedback suggests extracting the document.body theme synchronization logic into a reusable helper method (syncThemeToBody) to avoid code duplication between applyThemeToDom and attachRenderer, and to simplify class toggling.

Comment thread bridge/src/preview-bridge.ts Resolved
Comment thread bridge/src/preview-bridge.ts Resolved
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 1232580):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

TAG=agy
CONV=13dfcb37-0b15-42e8-a26b-0c91b22c4741
@jgindin
jgindin merged commit 0e17f8f into main Aug 5, 2026
13 checks passed
@jgindin
jgindin deleted the fix-dark-light-mode branch August 5, 2026 17:43
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