-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use @emotion/server
for server-side security prompts
#142662
Conversation
{/* eslint-disable-next-line react/no-danger */} | ||
<style dangerouslySetInnerHTML={{ __html: `</style>${emotionStyles}` }} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick explanation on why this creates a blank <style></style>
tag:
-
Since Emotion is returning its styles as one giant HTML string (including specific classes/attributes on its
<style>
tags that we likely should not ignore), we need to usedangerouslySetInnerHTML
-
The number of children allowed within the
<head>
tag is limited, e.g. no<div>
s or otherwise handy 'grouping' type tag. If you try to use a tag that normally does not have children, e.g. the<meta>
tag, Kibana/React will error with[ERROR][http.server.Kibana] Error: meta is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.
-
style
was therefore the tag that made the most sense, but causes weird/unnecessary nesting behavior, hence the prepended</style>
. See this StackOverflow answer for how this works. This ends up creating a blank<style></style>
tag, but that really isn't the worst thing in the world, and is an unfortunate necessary evil until React supportsdangerouslySetInnerHTML
on fragments.
@kc13greiner Does this need to be backported to 8.4? Not sure if Ops would have any issue with that considering the extra dependency/dependency upgrades, but in general they shouldn't be risky. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No, 8.5 is sufficient here. The regression was introduced via #140323, which wasn't backported to 8.4 as far as I can tell. Thanks for working on this fix for us, @constancecchen! |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
@legrego @kc13greiner I think I lost track of my FF releases 🙈 Is 8.5 the one that just went into FF and 8.6 is latest main? If so, do we need to backport this manually to 8.5? edit: backported #142689 |
It looks like you figured this out already, but to close the loop: Yes, 8.5 just went into FF, so |
* Update all `@emotion` dependencies to latest * Install `@emotion/server` * Use Emotion server-side rendering for security prompt pages * snapshots
* Update all `@emotion` dependencies to latest * Install `@emotion/server` * Use Emotion server-side rendering for security prompt pages * snapshots
Summary
closes #124490
In #134919, EUI updated Security's
prompt_page
template to correctly support the CSS of Emotion-converted components. At the time, styling was working and Emotion was outputting its CSS styles into<body>
tags. At some point between then (June) and now, Emotion styles stopped rendering correctly / as expected.The solution is to this is to utilize
@emotion/server
for server-side rendering. In addition to fixing the now-broken/missing Emotion styles, this also has the added benefits of:<head>
and not the<body>
, reducing potential CSS specificity issues:first-child/:nth-child
selectorsThis PR also incidentally updates all Kibana's various
@emotion
dependencies to the latest minors.Before
After