Issue #3075💬 AnsweredOpened October 16, 2020by hellocaio0 reactions

Unhandled Rejection (TypeError): i.classList is undefined

快速解答by hellocaio

Never mind, problem solved by: editor.on("load", () => { editor.on("component:add", (model) => { editor.select(model); }); });

Read full answer below ↓

Question

Hi. I updated GrapesJS to its current version 0.16.22 and I get an error on the callback function:

editor.on("component:add", (model) => {
    editor.select(model);
});

The error stack:

Unhandled Rejection (TypeError): i.classList is undefined

Stack:
./node_modules/grapesjs/dist/grapes.min.js/</</w.toggleClass/</<
node_modules/grapesjs/dist/grapes.min.js:2
S
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</w.toggleClass/<
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</w.each/<
node_modules/grapesjs/dist/grapes.min.js:2
S
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</w.each
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</w.toggleClass
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</w.removeClass
node_modules/grapesjs/dist/grapes.min.js:2
updateStatus
node_modules/grapesjs/dist/grapes.min.js:2
m
node_modules/grapesjs/dist/grapes.min.js:2
v
node_modules/grapesjs/dist/grapes.min.js:2
d
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</</o</a.Backbone</c.trigger
node_modules/grapesjs/dist/grapes.min.js:2
set
node_modules/grapesjs/dist/grapes.min.js:2
selectAdd
node_modules/grapesjs/dist/grapes.min.js:11
init/<
node_modules/grapesjs/dist/grapes.min.js:11
m
node_modules/grapesjs/dist/grapes.min.js:2
v
node_modules/grapesjs/dist/grapes.min.js:2
d
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</</o</a.Backbone</c.trigger
node_modules/grapesjs/dist/grapes.min.js:2
_onModelEvent
node_modules/grapesjs/dist/grapes.min.js:2
m
node_modules/grapesjs/dist/grapes.min.js:2
v
node_modules/grapesjs/dist/grapes.min.js:2
d
node_modules/grapesjs/dist/grapes.min.js:2
./node_modules/grapesjs/dist/grapes.min.js/</</</o</a.Backbone</c.trigger
node_modules/grapesjs/dist/grapes.min.js:2
set
node_modules/grapesjs/dist/grapes.min.js:2
add
node_modules/grapesjs/dist/grapes.min.js:2
push
node_modules/grapesjs/dist/grapes.min.js:2
addSelected/<
node_modules/grapesjs/dist/grapes.min.js:11
addSelected
node_modules/grapesjs/dist/grapes.min.js:11
setSelected/<
node_modules/grapesjs/dist/grapes.min.js:11
setSelected
node_modules/grapesjs/dist/grapes.min.js:11
select
node_modules/grapesjs/dist/grapes.min.js:11

Answers (3)

hellocaioOctober 16, 2020
代码片段TEXT
Never mind, problem solved by:

    editor.on("load", () => {
        editor.on("component:add", (model) => {
            editor.select(model);
        });
    });
hellocaioOctober 16, 2020

Ok, never mind the previous never mind. It worked a few times now I'm getting the same error. Sorry about that.

artfOctober 16, 2020

Can you provide a demo, please?

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.