Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Unable to add class when adding Dom Component #2836

Closed
RJCAM opened this issue Jun 16, 2020 · 1 comment
Closed

[BUG]: Unable to add class when adding Dom Component #2836

RJCAM opened this issue Jun 16, 2020 · 1 comment

Comments

@RJCAM
Copy link

RJCAM commented Jun 16, 2020

GrapesJS Version used: 0.16.12 (current)

Just a strange behavior, I can add all the attributes I want when adding component directly inside canvas using dom components add function (like code below) but the editor always remove the class.

let component = editor.DomComponents.addComponent({
    tagName: 'div',
    content: 'Content text', // Text inside component
    style: {
        width: "100%",
        height: "100px",
        "background-color": "#ddd",
        color: 'red'
    },
    attributes: {
        title: 'divTitle', // This works
        id: "divID", // This works
        class: "someClass" // This is going to be removed
    }
});

The class is only added if we create the component first and then assign a class to it. Example, we add the code above and then we add the code below:

component.addAttributes({
    class: 'anotherClass'
});
@artf
Copy link
Member

artf commented Jun 18, 2020

Yeah, you have to use classes property, but I agree that is confusing (that because classes are treated a bit differently), so I'll try to make the initialization possible also with attributes.class value

@artf artf closed this as completed in d3a2e54 Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants