When you delete a component, duplicate classes between components will be deleted.
You should avoid putting shared styles in component-related ones. Check this discussion on how to prevent this: https://github.com/GrapesJS/grapesjs/discussions/5968
Read full answer below βQuestion
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 126.0.6478.127(Windows) Reproducible demo link https://jsfiddle.net/t06s4oLb/8/ Describe the bug How to reproduce the bug?Add section1 to canvasAdd section2 to canvas under section1remove section2 from canvas.The style of section1 will be broken. https://github.com/GrapesJS/grapesjs/assets/14024165/097dbe62-d8d3-4270-930d-5668ef10c2df What is the expected behavior? I would like it to not be deleted even if separate components have the same class. What is the current behavior? The reason is...
Answers (4)
You should avoid putting shared styles in component-related ones. Check this discussion on how to prevent this: https://github.com/GrapesJS/grapesjs/discussions/5968
As a temporary workaround, styles for each component are prefixed with id.
@artf thank you for your reply. I would like to confirm #5968
You've identified a common issue in GrapesJS related to how it manages CSS rules, especially when classes are shared between multiple components. This behavior can indeed lead to broken styles when a component is deleted. Root Cause Analysis The GrapesJS editor dynamically manages CSS rules based o...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4754
Closing `</script>` tag not escaped for script properties
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Version 107.0.5304.122 (64-bit) Rep...
Issue #4576
Clicking 'wrap for style' button affects the inner components of other components inside the same text box
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 104.0.5112.101 Reproducible demo link...
Issue #6706
TypeError: e.getRoot is not a function (Race condition in Style Manager)
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? All browsers (Chrome, Safari, Firefox, Edg...
Issue #5086
Style:property:update and Property onChange trigger excessively
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Version 112.0.5615.137 (Official Bu...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins βPremium plugins ship with support, regular updates, and production-ready features β save days of integration work.
Browse premium plugins βRelated tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins β TinyMCE Inline Text Editor and Placeholder.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.