Skip to content

feat: Global theming APIs#4559

Open
fralongo wants to merge 3 commits into
mainfrom
flongo-global-theming
Open

feat: Global theming APIs#4559
fralongo wants to merge 3 commits into
mainfrom
flongo-global-theming

Conversation

@fralongo
Copy link
Copy Markdown
Member

Description

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates. N/A
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md. Yes
  • Changes do not include unsupported browser features, see CONTRIBUTING.md. Yes
  • Changes were manually tested for accessibility, see accessibility guidelines. N/A

Security

Testing

  • Changes are covered with new/existing unit tests? Yes
  • Changes are covered with new/existing integration tests? Yes

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.42%. Comparing base (9c52a81) to head (5dd9821).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/theming/index.ts 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4559      +/-   ##
==========================================
- Coverage   97.42%   97.42%   -0.01%     
==========================================
  Files         938      938              
  Lines       29680    29716      +36     
  Branches    10788    10793       +5     
==========================================
+ Hits        28917    28952      +35     
- Misses        716      757      +41     
+ Partials       47        7      -40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/theming/index.ts
Comment on lines +45 to +58
interface WindowWithTheme extends Window {
[themeStorageKey]?: Theme;
}

function getTopWindow(): WindowWithTheme {
try {
if (window.top) {
return window.top as WindowWithTheme;
}
} catch {
// Cross-origin access error — fall back to current window.
}
return window as WindowWithTheme;
}
Copy link
Copy Markdown
Member

@jkuelz jkuelz May 27, 2026

Choose a reason for hiding this comment

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

Is there a reason we go straight to the top vs using the findUpAPI that already exists for plugins?

We also use getTopWIndow in our ErrorBoundary component.

There is also a key piece missing here that both of those have: the cross-origin SecurityError check -- which is only thrown when accessing writable properties on the window directly. We need to add that to the first statement to make the catch have any effect.

function getTopWindow(): WindowWithTheme {
    try {
      if (window.top && window.top.document) { // <-- this forces cross-orign to return the security error here
        return window.top as WindowWithTheme;
      }
    } catch {
      // Cross-origin top — fall back to current window.
    }
    return window as WindowWithTheme;

Should we use a shared utility here? We could've prevented this bug (and any future fixes that we may need to make).

Copy link
Copy Markdown
Member

@jkuelz jkuelz left a comment

Choose a reason for hiding this comment

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

Looks good, just one comment on the getTopWindow fn.

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