Skip to content

fix(app): inject emotion styles before legacy JSS styles - #1115

Open
bitsbeyond wants to merge 1 commit into
thomasnordquist:masterfrom
bitsbeyond:fix/emotion-jss-injection-order
Open

fix(app): inject emotion styles before legacy JSS styles#1115
bitsbeyond wants to merge 1 commit into
thomasnordquist:masterfrom
bitsbeyond:fix/emotion-jss-injection-order

Conversation

@bitsbeyond

Copy link
Copy Markdown

Problem

Emotion (MUI v5+) appends its stylesheets to <head> after the JSS stylesheets generated by the legacy @mui/styles withStyles/makeStyles. With equal selector specificity the emotion rules win, so every legacy JSS override in the app silently stops applying.

Visible symptoms include:

  • the gap between the "MQTT Connection" dialog title and the connection URL disappears (marginLeft from withStyles is ignored),
  • sidebar tab labels render in the wrong letter case,
  • assorted small margins/paddings across the app fall back to component defaults.

Fix

Wrap the app in StyledEngineProvider injectFirst, the interop setup MUI documents for codebases that still use @mui/styles. Emotion styles then land first in <head> and the JSS overrides win again, restoring the cascade the components were written against.

Verification

Checked computed styles via DevTools before/after (e.g. the dialog URL marginLeft: 32px returns). yarn test:app unchanged (103 passing, 4 pre-existing failures).

🤖 Generated with Claude Code

Emotion (MUI v7) appended its stylesheets after the JSS ones generated
by @mui/styles, so every legacy withStyles/makeStyles rule with equal
specificity lost to the component defaults. Visible symptoms included
the missing gap between the connection dialog title and its URL and tab
labels rendering in the wrong case. StyledEngineProvider injectFirst
restores the intended cascade for the whole app.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@bitsbeyond

Copy link
Copy Markdown
Author

Same CI situation as #1114: all Actions jobs fail inside actions/checkout in the pull_request_target workflows before any project code runs — analysis in #1114 (comment) (latest comment there).

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.

1 participant