Skip to content

Commit

Permalink
Prevent rendering of RichTextBlock without content (#2585)
Browse files Browse the repository at this point in the history
Currently, blocks using the `PreviewSkeleton` are rendered empty in the
site if they do not contain any content. This causes unwanted HTML tags
in the site. This change prevents these blocks from being rendered
without content.

---------

Co-authored-by: Stefanie Kaltenhauser <[email protected]>
Co-authored-by: Johannes Obermair <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent db44357 commit b0de0bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .changeset/wise-mirrors-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@comet/cms-site": patch
---

Prevent rendering of empty blocks in `PreviewSkeleton`

Previously, in non-preview environments, `PreviewSkeleton` would still render its children, even if `hasChanges` was set to `false`, causing unwanted empty HTML tags in the site.
For instance, an empty rich text block would still render a `<p>` tag.
Now, the children will only be rendered if `hasContent` is set to `true`.
Doing so removes the need for duplicate empty checks.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const PreviewSkeleton = ({
);
}
}

if (!hasContent) {
return null;
}

return <>{children}</>;
};

Expand Down

0 comments on commit b0de0bd

Please sign in to comment.