Skip to content
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

core: allow to control style tag insertion location #332

Closed
spmonahan opened this issue Feb 6, 2023 · 2 comments · Fixed by #346
Closed

core: allow to control style tag insertion location #332

spmonahan opened this issue Feb 6, 2023 · 2 comments · Fixed by #346
Assignees
Labels
💅 enhancement New feature or request

Comments

@spmonahan
Copy link
Contributor

Internally Griffel ensures its style tags are inserted in the correct order to provide deterministic results. However, when used in an application that lazy loads code and styles, Griffel's style tags may become interleaved with the application's style tags, resulting in non-deterministic results.

This manifests in real-world applications that use lazy loading of React components (and CSS modules for application styles in this case but I don't think that's necessarily relevant) and Fluent UI React v9 for controls. In this case application authors want to override default Fluent styles with their own CSS but because their components are lazily loaded and they cannot control where Griffel styles are loaded in the document they cannot be guaranteed their styles will have greater specificity than Fluent's built in Griffel styles.

I've created a rough demo of this on Codesandbox: Griffel Lazy Load

With the default example, by inspecting the source, you can see how some application CSS is loaded in the document first, then Griffel styles, then more app CSS.

I'd like an API for Griffel that allows me to control where Griffel's style tags are inserted so I can ensure they are in the correct place relative to my application's styles.

@layershifter layershifter added the 💅 enhancement New feature or request label Feb 7, 2023
@layershifter layershifter changed the title Allow authors to control Griffel style tag insertion location core: allow to control Griffel style tag insertion location Feb 10, 2023
@layershifter layershifter changed the title core: allow to control Griffel style tag insertion location core: allow to control style tag insertion location Feb 10, 2023
@layershifter
Copy link
Member

We need to keep all style elements created by a Griffel in a group. To ensure that it's true we need to keep the existing approach with style buckets and being them siblings.

The more reasonable option for me is insertionPoint, going to create a PR with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💅 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants