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

JSS Dynamic Rules are not removed on re-render V10.0.9 #1616

Open
avgurf opened this issue May 23, 2022 · 0 comments
Open

JSS Dynamic Rules are not removed on re-render V10.0.9 #1616

avgurf opened this issue May 23, 2022 · 0 comments

Comments

@avgurf
Copy link

avgurf commented May 23, 2022

Expected behavior:
Once new css rules are added older css rules should be deleted from DOM

Describe the bug:
When i use dynamic selectors in dynamic styles, the new rules are added while the older ones are not removed from DOM resulting in elements having style while the current state doesn't require them to have this style.
Noticed it used to work in JSS v9.07 and stopped working from V10.0.0+

Reproduction:
open the codesandbox bellow and:

  1. click on a box to select it and make it change the color to red using the dynamic selector
  2. click again and notice the older dynamic selector is still in the DOM resulting the button to become red

Codesandbox link:
https://codesandbox.io/s/react-jss-playground-forked-o7fmy1

further explanation:
i know the example i give doesn't look like the common use case, sure you can apply a class for selected items, but in my project i really heavily on SVGs in a way which i would want to manipulate some inner paths to paint in different colors or locations based on state, for that reason i needed to have dynamic selectors to be able to color inner paths in the svg component, i did found a work-around by adding a unique class name to the svg container in each render, and applying new css rules on a &.timespamp svg[id=${id}] selector. but i do experience some animalities when for some millseconds the newer style wasn't yet rendered on DOM but the class name timestamp already changed and the entire component entirely loses its style for a brief moment

Versions (please complete the following information):

  • jss:10.0.9

Screenshots:
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant