BUG: Symbols break when loading pages progressively (instances lose __symbol link)
Here is a video showing the bug:
https://github.com/user-attachments/assets/0fdc76ed-cee5-4481-98b1-cbbf52572b31
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
firefox latest and Chrome v141.0.7390.122
Reproducible demo link
I can do a fiddle/codepen if needed, or you can reproduce using https://canary.silex.me (you need a gitlab.com account), no setup needed, bug reproduces immediately
Or even easier, without a gitlab.com account:
npx @silexlabs/[email protected]Then you have a blank site on http://localhost:6805
Describe the bug
Hello!
When loading a project progressively (pages loaded one by one to avoid browser freez, like this code), it breaks the Symbols bidirectional link:
- Instance → main symbol sync works - i had to add
editor.trigger('symbol')for that to work - Main symbol → instances sync fails
- Instance → Instance fails (this is a result of the Main → Instance problem)
The root cause seems to be that GrapesJS correctly resolves __symbols (array of instance refs) but instances keep __symbol: 0 if they were created later (after the symbols), so the link stays broken
Maybe what we need is a non-blocking way of loading many pages, or a way to have symbols "linked" after loading each page, or both :)
Reproduce
- Create a symbol
- Place two instances of that symbol on the canvas (same page or different pages)
- Save the project
- Reload the editor (pages load progressively)
- Edit one of the two instances (style, attributes, or text via RTE)
Expected
The changes should be applied to the other instance
Actual
The changes are not applied to the other instance, but if you drop another instance on the canvas, it will have the latest changes from after reload
Note: Instances have __symbol: 0, so changing the instance never updates the symbol
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: GrapesJS/grapesjs