-
Notifications
You must be signed in to change notification settings - Fork 176
fix: move style element to document head #81
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
Conversation
|
This change has several issues:
I don't really care about making some validator happy. All browsers I have tested this in support this pattern, and not doing this only causes issues. |
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.
I agree, I don't think that we can accept this approach. How about we add an opt-in flag to remove the default <style> injection and export the styles as a variable? This way, developers that are willing to do the extra mile can move the style into the head, e.g. using emotion Global component.
In the case of Material-UI, it's important that the output of https://validator.w3.org/ doesn't shallow issues with the components. In this case <style> element inside the body is discouraged by the spec because it leads to reflow during the initial rendering, degrading performance.
Alternatively, @mbrookes did you consider not rendering react-simple-code-editor in the initial SSR output?
|
Also, note that |
|
satya164 1 & 2a: Since the CSS sets the font color of placeholder text for the underlying textfield, before which it's transparent, there's no FOUC or re-layout. What's the underlying concern?
"We add HTML validation warnings. [...] They can all be fixed in react-simple-code-editor" So, no.
I don't think having a prop to enable rendering valid HTML, with the added dev overhead of injecting the styles locally, is a good tradeoff. NoSsr will do. |
@mbrookes From what I understand, the issue with the placeholder color is that, when the source is empty, the placeholder would flash at the hydration time. So the current solution doesn't work. |
|
How about we:
? Only IE would get a degraded experience. |
CSS does 2 things:
It does if you want to solve the above issues when doing SSR
If a component does some side-effect like adding elements to the page, it should also cleanup the elements after it's no longer there. The problem with cleanup here is that there's one global style inserted by the component, so removal won't be possible cleanly, but it's still a tradeoff. |
While I understand that IE supprting IE is no longer a priority, IMO degrading the experience just to make a validator/linter happy is a reasonable tradeoff. Linters are supposed to be helpful to identify potential errors, not an be an authority over what to do. Right now IE is a supported browser and the experience was as expected before the change. If we explicitly provide a degraded experience in a browser when we could avoid it, then we don't really support it. Also keep in mind that many other projects use the package, and they might need to support IE (though I have no data), and this change will break their UX. So we need to be mindful of such breaking changes. What's not important for you maybe important for others. How about we take another route? Keep the IE specific style in This will make the linter happy for your case, while also having an option to provide good UX for people who need IE support. |
|
The proposed approach with the boolean prop sounds great 👌 From my perspective, root of the issue is that body > style is not a great practice: whatwg/html#1605 (comment), it's discouraged for the very same regression the current changes introduce for IE SSR users: FOUC. I would imagine this package targets an audience of developers, hence IE support is not important (e.g. CodeSandbox/Next.js not supporting it for development). |
While generally it can be bad for performance, from my understanding, this isn't an issue in this particular case.
The thing is that it already supported IE properly, and we don't know if certain users realy on this. So regressing that would be a breaking change. Anyway, let's add the prop for now. |
Okay, let's take a step back here and be pragmatic. Nobody but nobody who is using IE11, an 8 year old browser, cares a bit about, or will even notice, a tiny FOUC. Half the internet doesn't work for them already. If it really, really worries you that much, let's drop IE11 support entirely, and bump the major version. IE11 is EOS in eight months. Microsoft are dropping support for it in O365 in six. It's dead Jim. |
Doesn't matter. I care about the quality of UX in projects I work on. |
|
Sounds like you're saying you prefer option two? |
|
I'd prefer not to drop support outright since it doesn't really take any work to maintain this and I would like to avoid breaking changes unless we have good reasons (e.g. maintainability etc.). So I propose to introduce a prop which addresses both use cases: not do a breaking change, and also passes HTML validation for those who don't need IE support. |
|
And if it causes more issues in future, then we should definitely drop support for IE and do a major version bump. |
|
Just realised it's still version 0 anyway, so no need for a version bump for breaking changes according to SemVer. We can add the prop now, and could rip it out again in October with no qualms. |
|
I do like the idea of degrading the experience for IE users, to create an incentive to upgrade and not penalize modern browsers. We have done that many times in Material-UI, basically a best effort. What we have done is that if the support comes with a non reasonable cost for modern browsers (here bundle size, mainly) we degrade the UX or DX (if it helps). @mbrookes What's wrong with the proposal for the opt-out prop for IE (outside of forcing bundle size)? #81 (comment) |
|
@oliviertassinari Personally I'd much prefer to just drop IE support instead of intentionally degrading the UX. If you strongly feel about not supporting IE then feel free to do a major release removing IE support. |
|
Also, bundle size will not be affected here either way unless we drop support entirely. |
Do you mean not significantly? Removing the whole style and associated CSS should be less code. Completely removing IE might be too bold for the us cases of Material-UI. It would effectively mean that our docs doesn't render in IE at all (right now, it's only Next.js that broke it in 2-3 places in dev mode). I would personally add a prop and move to something else. I don't think that the problem deserves a lot of attention. |
I mean this PR still keeps the CSS, so it won't change much. But removing whole style and associated CSS means dropping support entirely in which case it'd be a minor improvement. |
Agreed. It's simplest solution and makes everyone happy. |
|
Closing as it has been stuck for over a year. |
Motivation
Test plan
https://validator.w3.org/