From a1a93550db6b05afa010d0fc3baf9b244048f494 Mon Sep 17 00:00:00 2001 From: SebiVPS <42858722+SebiVPS@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:25:33 +0200 Subject: [PATCH] RichTextBlock: only render `div` when `disableLastBottomSpacing` is set (#292) prevents invalid html when div is rendered inside p tag when a Typgraphy is wrapped around the RichTextBlock --------- Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com> --- site/src/common/blocks/RichTextBlock.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/site/src/common/blocks/RichTextBlock.tsx b/site/src/common/blocks/RichTextBlock.tsx index 093afd3d4c..1326250ae2 100644 --- a/site/src/common/blocks/RichTextBlock.tsx +++ b/site/src/common/blocks/RichTextBlock.tsx @@ -130,7 +130,7 @@ export const RichTextBlock = withPreview( return ( - {rendered} + {disableLastBottomSpacing ? {rendered} : rendered} ); }, @@ -145,9 +145,8 @@ export const PageContentRichTextBlock = (props: RichTextBlockProps) => ( ); -const Root = styled.div<{ $disableLastBottomSpacing?: boolean }>` - ${({ theme, $disableLastBottomSpacing }) => - $disableLastBottomSpacing && +const DisableLastBottomSpacing = styled.div` + ${({ theme }) => css` > *:last-child { margin-bottom: 0;