Empty Block Style Attributes Bug?

Hi,

If you add a attribute to a block and Use as Style then it outputs it even when empty.
Example settings:
image

Example Output:
image

Should it not output anything unless that field is being used? If possible?

Thanks
Guido

1 Like

Nice find. Needs to be fixed IMHO. @matjaz

2 Likes

Hi @matjaz

Just wanted to follow up on this.

I am in the process of creating some standard blocks with some standard options.

In most cases i want it to be inline styles. But not if it outputs all the inline styles when not used. Let’s say you use 10 options for inline styles then it outputs all 10 inline styles like the example above. Just gets messy html wise with all empty inline styles that are being outputted.

Plus in some cases it clashes with the styles that the block already has. For example if you want to change a variable with the inline styles then it also outputs an empty variable when the option is not used. Resulting in the variable in the styles that the block already has also to become empty.

So is this a bug or is this just how it works and can’t be changed? If it is just s a bug that can be fixed soon then i will go the inline styles route once fixed. If not then i will find go another route.

Thanks
Guido

Hi @Guido yes, it is a bug and will be fixed in the next release, planned for the next week.
Thanks!

Hi @matjaz

Great good to hear! :wink: Then i also found a bug when you use a variable as default. If you do the following:

image

Then you get a critical error on the front-end:

If you leave default value empty like this:

image

Then everything works fine. Hope that can be fixed too :wink:

Thanks!
Guido

Thanks @Guido, I fixed the issue with CSS vars in default value.

Regarding empty style properties - React blocks now do not show empty properties if value is not set, but that change is much harder to implement for dynamic and hybrid blocks. There, the empty style property is still present. If that is an issue, it is best to use CSS classes instead of style properties directly.

2 Likes

Hi @matjaz

Awesome thanks!

Oke sounds good. Then for dynamic and hybrid i will use another approach.

Thanks!
Guido

1 Like