Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CSS modules can't handle prefixes #4028

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

Open
CryZe opened this issue Apr 22, 2025 · 0 comments
Open

CSS modules can't handle prefixes #4028

CryZe opened this issue Apr 22, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@CryZe
Copy link
Contributor

CryZe commented Apr 22, 2025

Problem

If I have a CSS module like so:

.sidebar { 
    background: red;
    padding: 20px;
}
.sidebarButton {
    background: blue;
}

then the Classes::sidebar_button class doesn't actually work. The reason is that because it has the same sidebar prefix as an already mangled class, it mangles the prefix on accident instead of the entire class.

.sidebarfb811ee670c8c644 {
    background: red;
    padding: 20px
}

.sidebarfb811ee670c8c644Button {
    background: #00f
}

in the DOM it's correct, but due to the mismatch can't find the class:

<div class="sidebarfb811ee670c8c644">
    <button class="sidebarButtonfb811ee670c8c644">Hi</button>
</div>

Steps To Reproduce

Steps to reproduce the behavior:

css_module!(Classes = "/assets/sidebar.css");

#[component]
pub fn Sidebar() -> Element {
    rsx! {
        div { class: "{Classes::sidebar}",
            button { class: "{Classes::sidebar_button}", "Hi" }
        }
    }
}

Expected behavior

The button should be blue.

Screenshots

Image

Environment:

  • Dioxus version: 1001d78
  • Rust version: 1.86
  • OS info: Windows 11
  • App platform: desktop

Questionnaire

I'm interested in fixing this myself, if no one else fixes it.

@CryZe CryZe added the bug Something isn't working label Apr 22, 2025
@DogeDark DogeDark self-assigned this Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants