Short description of issue
In Liquid sections, section.id may contain equals symbols breaking CSS selectors. This occurs when displayed in the editor section preview.
Reproduction steps
Take any section in any theme that includes a CSS selector built using section.id. Here is an example from Dawn:
Add simple CSS that would have a clear effect.
For example, in Dawn’s sections/image-banner.liquid, adding these at line 30 should hide the image and turn the background red:
#Banner-{{ section.id }} { background: red }
#Banner-{{ section.id }} .banner__media { display: none }
This CSS is not applied in the section preview, but it is when you add the section to the page.
The section preview is inserting equals symbols (=) into the section.id, making the CSS selector invalid. This character would need escaping in CSS.
Additional info
This has been the cause of sections in our themes not appearing in the section preview, and has been going on for many months.
On the surface it seems like a simple fix this, which will increase the stability of the theme customiser.
If section.id can be relied on in CSS selectors, and Dawn’s CSS implies it should, then it should never contain invalid characters like this.
The screenshot shows how the padding CSS in Dawn’s sections is never applied to the section, as observed in dev tools.
What type of topic is this
Bug report
