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

Selector [contenteditable] is not pure. Issue with importing scss file #387

Open
oskaryil opened this issue Apr 22, 2024 · 11 comments
Open
Assignees
Labels
help wanted Extra attention is needed

Comments

@oskaryil
Copy link

Describe the bug

I'm using sass in a Next.js React project. I'm unable to import the react-grid scss into my scss file.

$primary-color: #fff !default;

@import '@silevis/reactgrid/styles.csss';

Current behavior
It's giving me this error:

  156 | }
  157 | 
> 158 | [contenteditable] {
      |                                                 ^
  159 |   -webkit-user-select: text;
  160 |   user-select: text;
This error occurred during the build process and can only be dismissed by fixing the error.

Expected behavior
I'd like to override the scss variables to edit the styles of the react-grid component.

Screenshots or gifs
image

Your environment details

  • Device: Desktop
  • OS: macOS
  • Browser: Chrome
@webloopbox
Copy link
Contributor

webloopbox commented Apr 23, 2024

@oskaryil I've checked this and importing the scss file in a nextjs project with the latest version of ReactGrid should work correctly. Could you provide a sandbox with the reproduced issue?

@oskaryil
Copy link
Author

oskaryil commented Apr 23, 2024

@oskaryil I've checked this and importing the scss file in a nextjs project with the latest version of ReactGrid should work correctly. Could you provide a sandbox with the reproduced issue?

Strange. I have a more or less clean project using this template https://github.com/theodorusclarence/ts-nextjs-tailwind-starter. Did you try importing the scss file inside your own scss file?

@webloopbox
Copy link
Contributor

webloopbox commented Apr 24, 2024

Strange. I have a more or less clean project using this template https://github.com/theodorusclarence/ts-nextjs-tailwind-starter.
Did you try importing the scss file inside your own scss file?

Yes, I have prepared a nextjs (14.2.0) template with the latest version of ReactGrid. Please take a look:
https://stackblitz.com/edit/yet-another-react-lightbox-nextjs-nfavno?file=package.json

@MichaelMatejko MichaelMatejko added the help wanted Extra attention is needed label Apr 24, 2024
@webloopbox
Copy link
Contributor

@oskaryil Is this issue still relevant?

@Igormandello
Copy link

Igormandello commented Apr 30, 2024

Hey there!

This might happen because "non-pure" selectors are not allowed inside module SCSS files. I had this issue when importing my <component>.module.scss inside the <component>.tsx file.

For me, the solution was pretty straightforward:

  • Move your custom SCSS file to ./src/styles/reactgrid.scss
  • Import it inside ./src/pages/_app.tsx

If you want to know why this happens, please take a look at this discussion

EDIT: If you don't want to import the custom variables globally, follow this approach.

@webloopbox
Copy link
Contributor

webloopbox commented May 6, 2024

Thanks for this thread. At the moment, reactgrid.scss contains one global selector, so it can't be imported as .module.scss due to constraints imposed by Next.js.

@MichaelMatejko
Copy link
Contributor

I agree with the message on the screenshot with black background: add class to make it pure

@Igormandello
Copy link

@webloopbox Even though I found the usage of contenteditable in the code during the copy handler, I couldn't figure out where it's being applied. Do we really need it?

@webloopbox
Copy link
Contributor

@Igormandello This selector was likely added with Safari browsers in mind. The most sensible approach would be to apply a CSS class to this.

@Igormandello
Copy link

@webloopbox I have implemented something really similar to #402 and while testing I noticed something:
We don't need to remove the [contenteditable], because in the end - if we want to import styles.scss inside a .module file - we will need to compensate the global class names using a :global selector inside the module class.

For example, one way of using it as a module could be:

// custom.module.scss

$primary-color: #4285f4;

.my-custom-module {
  :global {
    @import "@silevis/reactgrid/styles.scss";

   .rg-input {
      border: none;
    }
  }
}

and then, inside your component:

// Component.tsx

import style from "~/styles/custom.module.scss";

export default function Component() {
  return (
    <div className={style["my-custom-module"]}>
      {/* ReactGrid component */}
    </div>
  );
}

Even if we remove the [contenteditable] selector, the module will still not be pure unless we wrap it inside a custom class. If we wrap it inside a custom class, we don't need to remove the selector.

@oskaryil
Copy link
Author

Hey there! This might happen because "non-pure" selectors are not allowed inside module SCSS files. I had this issue when importing my <component>.module.scss inside the <component>.tsx file.

For me, the solution was pretty straightforward:

  • Move your custom SCSS file to ./src/styles/reactgrid.scss
  • Import it inside ./src/pages/_app.tsx

If you want to know why this happens, please take a look at this discussion

Thanks! I just tried doing it this way and it works. I'll proceed with this workaround for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants