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: Propagating component defaults can break layers when child comments are introduced #5720

Closed
2 tasks done
bernesto opened this issue Mar 6, 2024 · 1 comment
Closed
2 tasks done

Comments

@bernesto
Copy link
Contributor

bernesto commented Mar 6, 2024

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Chrome v122

Reproducible demo link

https://jsfiddle.net/n38vbktg/

Describe the bug

How to reproduce the bug?

  1. Create a component that propagates defaults that include layerable = true.
  2. Introduce a comment under the competent.

What is the expected behavior?
The comment either remains hidden, or does not cause an error.

What is the current behavior?
The editor treats the comment as an HTMLElement. This triggers several errors when the editor tries to read non-existent properties from the node, such as getComputedStyle or getClientRects. Both methods should perform a check first. Or - a new type should be introduced for comments that overrides the defaults propagated from the parent.

Errors occur here:

var style = window.getComputedStyle(el);

and here:
return el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);

Code of Conduct

  • I agree to follow this project's Code of Conduct
@artf
Copy link
Member

artf commented Mar 7, 2024

Good catch @bernesto

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