Issue #3832πŸ’¬ AnsweredOpened September 29, 2021by Sudhin350 reactions

The css classes are removed and the autogenerated ids for each html tags gets changed ( Example : ivj5m-2) after each reload

Quick answerby Sudhin35

Please guide me on this

Read full answer below ↓

Question

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Chrome

Reproducible demo link

Not there

Describe the bug

How to reproduce the bug?

Install the grapes js in react app Go to the editor and drag a component. ( Example : text component) Style the component using the style manager save it into DB and see the code in the editor Reload the page see the code in the editor

What is the expected behavior? The html tag ids and css for that ids should not be changes or erased even though if reload the editor

What is the current behavior? If we are reloading the editor after any changes , the ids in the html code change and the css for that ids getting erased off

If is necessary to execute some code in order to reproduce the bug, paste it here below:

  const editor = grapesjs.init({
        container: "#block",
        canvas: {
          styles: [
            "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
          ],
Code SnippetTEXT
scripts: [
                "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js",
                "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js",
              ],
            },
            protectedCss: "",
            commands: {
              defaults: [
                {
                  id: "my-command-id",
                  run() {
                    alert("This is my command");
                  },
                },
              ],
            },
            plugins: ["gjs-preset-webpage"],
            storageManager: {
              id: "gjs_",
              type: "remote",
              autosave: true,
              autoload: true,
              urlStore: this.API_URL + "update_builder/" + this.state.id,
              urlLoad: this.API_URL + this.state.id,
              //method: 'patch',
              params: {
                draft: "1",
              },
              headers: {},
            },
            assetManager: {
              storageType: "",
              storeOnChange: true,
              storeAfterUpload: true,
              upload: "https://localhost/assets/images", //for temporary storage
              assets: [],
              uploadName: "file",
              uploadFile: function (e) {
                var files = e.dataTransfer
                  ? e.dataTransfer.files
                  : e.target.files;
                var formData = new FormData();
                for (var i in files) {
                  formData.append("upload", files[i]); //containing all the selected images from local
                }
                PageService.contentUpload(formData)
                  .then((response) => {
                    console.log(response.data.path);
                    editor.AssetManager.add(response.data.path);
                  })
                  .catch((error) => {
                    // this.alert.show(error.response.data.message,{type:'error'});
                  });
              },
            },
            pageManager: {
              pages: this.pagesList,
            },
            layerManager: {
              appendTo: ".layers-container",
            },
            styleManager: {
              appendTo: '.style-container' 
            },
          });

          const pageManager = editor.Pages;
          const pagesList = pageManager.getAll();
          this.pages = pagesList;
          this.editorData = editor;
          editor.store((res) => (this.callBackAlert = true));

          editor.on("storage:start:store", (objectToStore) => {
            console.log(objectToStore);
          });




          Banner(editor);
          // Resizing the components
          editor.on("component:selected", function (args) {
            args.set("resizable", true);
          });




### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Answers (4)

Sudhin35β€’ September 29, 2021

Please guide me on this

artfβ€’ September 29, 2021

Disable autoload: true you're loading everything twice

Sudhin35β€’ September 29, 2021

Thanks @artf . This fixed my issue

ClaudeCodeβ€’ May 17, 2026

Thanks for reporting this, @Sudhin35.

Great question about The css classes are removed and the autogenerated ids for each html tags gets changed ( Example : ivj5m-2) after each reload. The recommended approach with StyleManager is to use the event-driven API.

Start here:

  1. Check the GrapesJS documentation for your specific module
  2. Look for the on() event listener method
  3. Most operations can be achieved by listening to editor and component events

Common patterns:

// Listen for changes
editor.on('change', () => console.log('something changed'));

// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));

If you're still stuck:

  • Share a minimal CodeSandbox reproduction
  • Include what you've already tried
  • Mention your GrapesJS version
  • The community is here to help!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.