fix(embedded): add box-sizing and font-size reset for embedded dashboards#38536
fix(embedded): add box-sizing and font-size reset for embedded dashboards#38536kevin3274 wants to merge 1 commit intoapache:masterfrom
Conversation
…ards In standalone mode, antd's <Layout> component injects `box-sizing: border-box` and `font-size: 14px` via CSS-in-JS. Embedded mode does not render <Layout>, so these rules are never injected, causing: 1. Chart spacing/gaps to disappear (missing box-sizing) 2. Larger font rendering with less visible content (browser default 16px vs 14px) This adds an EmbeddedGlobalStyles component that uses the theme's fontSize token to ensure consistent rendering between standalone and embedded modes. Fixes apache#37493
Code Review Agent Run #86bca9Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I already have an approved pr to fix box-sizing here: #38351. Can you include the change for font-sizes on top of that? Thank you for fixing these! |
There was a problem hiding this comment.
Pull request overview
Adds missing global CSS rules to embedded dashboard rendering so embedded mode matches standalone antd <Layout> defaults (fixing panel overlap from missing box-sizing and oversized text from missing font-size).
Changes:
- Introduce
EmbeddedGlobalStylesthat injects abox-sizing: border-boxreset for all elements in embedded mode. - Set embedded
bodyfont-size using the active Superset theme token (theme.fontSize) to align with standalone dashboards. - Render the new global styles within
EmbeddedContextProvidersso they inherit the correct theme.
You can also share your feedback on Copilot code review. Take the survey.
User description
Summary
Embedded dashboards rendered via
superset-embedded-sdkare missing CSS rules that the standalone mode gets from antd's<Layout>component via CSS-in-JS. This causes:box-sizing: border-boxmeans padding is added outside element width, causing adjacent panels to overlapfont-size: 16pxinstead of the14pxthat antd's<Layout>provides in standalone mode (~14% larger)Root Cause
In standalone mode, the component tree is:
In embedded mode, the component tree is:
antd v5 uses CSS-in-JS with on-demand injection — component-level CSS is only injected when the component renders. Since embedded mode never renders
<Layout>, the following CSS rules are never injected:Fix
Added an
EmbeddedGlobalStylescomponent that injects the missing CSS rules using Emotion's<Global>component, using the theme'sfontSizetoken for consistency:box-sizing: border-boxon*, *::before, *::afterfont-sizeonbodyusingtheme.fontSize(default 14px from antd)Related PRs
box-sizing(approved, on hold for testing)box-sizing(maintainer requested scoping)box-sizingon.dashboard-component-chart-holderThis PR extends the approach of #38351 to also fix the font-size discrepancy, which none of the existing PRs address.
Fixes #37493
Test Plan
superset-embedded-sdk🤖 Generated with Claude Code
CodeAnt-AI Description
Restore layout box-sizing and font size in embedded dashboards
What Changed
Impact
✅ Restored chart gaps and spacing in embedded dashboards✅ Consistent font size between embedded and standalone dashboards✅ Fewer layout overlaps in embedded embeds💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.