diff --git a/.changeset/chilly-bikes-scream.md b/.changeset/chilly-bikes-scream.md new file mode 100644 index 000000000..6e162aa88 --- /dev/null +++ b/.changeset/chilly-bikes-scream.md @@ -0,0 +1,5 @@ +--- +'@hashicorp/react-enterprise-alert': patch +--- + +Fix EnterpriseAlert so that it does not potentially generate invalid markup when used inline diff --git a/packages/enterprise-alert/index.tsx b/packages/enterprise-alert/index.tsx index b0eb38edf..1b3239ada 100644 --- a/packages/enterprise-alert/index.tsx +++ b/packages/enterprise-alert/index.tsx @@ -23,8 +23,12 @@ function EnterpriseAlert({ className, }: EnterpriseAlertProps) { const { name, slug, themeClass } = useProductMeta(product) + + // This ensures we aren't producing invalid HTML when rendering inline alerts within MDX. When used inline, we might end up nesting a div inside of a p. This is invalid as p cannot contain block-level elements (ref: https://www.w3.org/TR/html401/struct/text.html#h-9.3.1). + const Element = inline ? 'span' : 'div' + return ( -
)} -
+ ) }