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

Incorrect implementation of prefixCssSelectors #377

Closed
a-ignatov-parc opened this issue Sep 9, 2024 · 4 comments
Closed

Incorrect implementation of prefixCssSelectors #377

a-ignatov-parc opened this issue Sep 9, 2024 · 4 comments
Labels
bug Something isn't working styles

Comments

@a-ignatov-parc
Copy link
Contributor

The current implementation of prefixCssSelectors (ref) doesn't properly handle prefixing css rules in media queries, which results in broken layouts during the initial render until the hydration is finished and styles are re-rendered with JS.

image

Here's an example of how the current implementation handles media queries

html:not([data-theme='dark']) .jdZmzL {
    z-index: 1;
    position: relative;
    overflow: hidden;
    width: calc(100% - 300px);
    contain: layout;
}

@media print,html:not([data-theme='dark']) screen and (max-width: 50rem) {
    .jdZmzL {
        width:100%;
    }
}

The issue is that the jdZmzL class in the media query has a lower specificity than the initial one, which results in ignoring its styles.

image

The correct result would be as follows

html:not([data-theme='dark']) .jdZmzL {
    z-index: 1;
    position: relative;
    overflow: hidden;
    width: calc(100% - 300px);
    contain: layout;
}

@media print, screen and (max-width: 50rem) {
    html:not([data-theme='dark']) .jdZmzL {
        width:100%;
    }
}
image
@rohit-gohri
Copy link
Owner

rohit-gohri commented Sep 9, 2024

Thanks for figuring this out, maybe this finally fixes #215

Would be great if you can open a PR too

@rohit-gohri rohit-gohri added bug Something isn't working styles labels Sep 9, 2024
@a-ignatov-parc
Copy link
Contributor Author

Would be great if you can open a PR too

@rohit-gohri, I've discussed this task with my team, and we've agreed to provide a fix either later this week or early next week. Will keep you posted 👍

@rohit-gohri
Copy link
Owner

Released as https://github.com/rohit-gohri/redocusaurus/releases/tag/v2.1.2

@a-ignatov-parc
Copy link
Contributor Author

@rohit-gohri, nice! Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working styles
Projects
None yet
Development

No branches or pull requests

2 participants