Skip to content

Improve iframe dark mode sync and prevent duplicate listeners#1365

Open
yasnazariel wants to merge 1 commit intobase:masterfrom
yasnazariel:patch-7
Open

Improve iframe dark mode sync and prevent duplicate listeners#1365
yasnazariel wants to merge 1 commit intobase:masterfrom
yasnazariel:patch-7

Conversation

@yasnazariel
Copy link
Copy Markdown

Overview

This PR improves the dark mode synchronization behavior for Chromatic iframes.

Changes

  • Prevent duplicate iframe load event listeners using a dataset flag
  • Add safety check for iframe.contentWindow before postMessage
  • Remove unnecessary setInterval polling logic
  • Optimize MutationObserver loop to avoid redundant executions
  • Improve attribute handling using setAttribute

Impact

  • Reduces unnecessary re-renders and event stacking
  • Prevents potential memory leaks
  • Improves performance and stability of theme synchronization

Notes

No functional UI changes — only internal improvements to iframe theme handling logic.

…sync

his update improves the dark mode synchronization logic for Chromatic iframes.

Changes include:
- Preventing duplicate event listeners using a dataset flag
- Adding safety checks before calling postMessage on iframe contentWindow
- Removing unnecessary polling via setInterval in favor of MutationObserver
- Optimizing mutation handling loop for better performance
- Using setAttribute for better DOM compatibilit
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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