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

OrderClass Not Creating Unique Selector #55

Open
dtcblyth opened this issue Feb 1, 2024 · 0 comments
Open

OrderClass Not Creating Unique Selector #55

dtcblyth opened this issue Feb 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dtcblyth
Copy link

dtcblyth commented Feb 1, 2024

Related thread: https://discord.com/channels/1041765492907589683/1079860683623116862/threads/1181261296423944343

The Problem:

For example, see this style in the Parent Module example, ModuleStyles, styles.tsx, line 66:

<CommonStyle
  selector={iconSelector}
  attr={attrs?.icon?.advanced?.color}
  property="color"
 />

iconSelector is:

const iconSelector = `${orderClass} .et-pb-icon`

When we set a color, the orderClass prop uses the module ID to create this selector:

.example_parent_module_d9d13485-a41a-41a9-b2e2-f125efdb900c .et-pb-icon {
    color: #e09900;
}

Which is the expected selector, BUT if I add another parent module, THAT COLOR IS ALSO APPLIED TO THE NEW CREATED MODULE because of this selector:

.example_parent_module_d04ee6bf-336e-4dac-b16a-422cdd227f83 .et-pb-icon {
    color: #e09900;
}

We haven't set any color in the d04ee6bf-336e-4dac-b16a-422cdd227f83 module yet, but the #e09900 color is also applied there. It looks like the orderClass is generating multiple selectors and therefore, all the styles you defined for a module will be applied to all modules.

To Reproduce:

You can see this by yourself. Just add a module that uses the orderClass prop in the module styles (e.g. icon color in the parent module), set a style from the module settings modal in order for the CSS to be generated, add the same module to the page and the style will be applied to the new module as well.

An Example:

Here’s a screen recording of the problem on a third-party module. Notice that adding border styles to the second instance of the module also affects the first instance. Also, when deleting the second module the styles in the first module are also removed.

2023-12-05_9-08-15_AM 2023-12-05_9_12_10_AM

@dtcblyth dtcblyth added the bug Something isn't working label Feb 1, 2024
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

No branches or pull requests

1 participant