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

CRITICAL: in development, CSS modules class names are not scoped and collide between sources of the same folder #5018

Closed
5 tasks done
jsamr opened this issue Jun 20, 2021 · 1 comment · Fixed by #5034
Closed
5 tasks done
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@jsamr
Copy link
Contributor

jsamr commented Jun 20, 2021

🐛 Bug Report

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io
  • I have read the console error message carefully (if applicable)

Description

In development, CSS modules class names are not scoped and collide between sources of the same folder

Have you read the Contributing Guidelines on issues?

Yes.

Steps to reproduce

  1. Create two components in the same folder, each with its own .module.css file.
  2. For each of those CSS modules, create a .root rule with a discernible background color.
  3. Import the root class in each of these component and apply the style to the top element returned by this component.
  4. Import and display those two components in a page.

Expected behavior

Each of these components background should be distinct, because each component should have a unique class name.

Actual behavior

Each of these components has the same background color, because each component has the same class name (e.g. root_src-components-. It looks like the method to extract a unique class name is missing the file name.

Your environment

Reproducible demo

https://codesandbox.io/s/docusaurus-css-collision-5xqmy?file=/src/pages/index.js

Remarks: I haven't tried to assess if this issue also happens in production yet.

@jsamr jsamr added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jun 20, 2021
@slorber
Copy link
Collaborator

slorber commented Jun 22, 2021

Thanks, will be fixed by #5034

Shouldn't happen in prod because we use shorter classnames including a hash

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants