Issue #2883○ OpenOpened July 8, 2020by j2l0 reactions

Ignore, bad use of Trait

待解决问题

No community answers yet. Open the original discussion on GitHub to share your solution.

Question

Hello,

Version: 0.16.18 Are you able to reproduce the bug from the demo? [X] Yes [ ] No

What is the expected behavior? Only add one trait, being able to test empty trait addition

Describe the bug detailed Adding trait with:

            const component = editor.getSelected();
            if (!component.getAttributes()['newtrait']) {
                component.addTrait('newtrait');
            }

Adds a new empty trait ... each time this component is selected: grapes

Because getAttributes is undefined:

editor.getSelected().getAttributes()['newtrait']
undefined

Until I fill newtrait with a value and newtrait value exists. It still keeps all the duplicate fields: grapes2

Maybe I missed something? Or is it a bug? Thank you EDIT: fixed by setting a value to the trait afterward :) Obvious, sorry!

Answers (0)

No answers yet.

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.