Rendering issue: variable in th
or caption
inside a Table component wrapped with another element
#1015
Labels
needs triage
Issue needs to be triaged
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Context
<table>
element inside a<figure>
element.th
andtd
, I use a simple<Table>
component with a slot and global styles.translate()
function.<th>
.Issue
The
<tbody>
of a<Table>
component is not correctly rendered when the component is wrapped with another element and that a variable is present in a<th>
(i.e.<thead><th>{myVariable}</th></thead>
) or in a<caption>
(i.e.<caption>{myVariable}</caption>
).For example:
Is rendered as below:
Instead of:
The rendering is correct only when:
<table>
element instead of the component,<Table>
component with a<figure>
,<th>
elements (and I don't add a<caption>
with a variable at the beginning of the table).Yet the
<Table>
component is very simple, for example:Workaround
<table>
element (instead of a component) and repeat the styles...<th>
and/or<caption>
(this is very inconvenient...)Reproduction
I put a Stackblitz link with a minimal reproduction.
src/pages/index.astro
is used to provide 3 different examples. The last one is the problem.src/components/base/table.astro
contains the very minimal Table component (I just define some styles to help visualize the problem).src/components/table-component-wrapped-in-figure.astro
is the problematic file.src/components/table-element-wrapped-in-figure.astro
andsrc/components/table-using-table-component.astro
are two examples where the rendering is correct using the same table (with variables).In
table-component-wrapped-in-figure.astro
:<th>{headingContent}</th>
with<th>Foo</th>
and you'll see that the table is now correctly rendered.<caption>{headingContent}</caption>
at the beginning of the table and you'll see the table is not rendered correctly again.Additional notes
I don't think the
<figure>
element is the problem here. While I was writing this issue, I tried to wrap the<Table>
component with a custom element instead of a<figure>
, and the same rendering issue occurs.What's the expected result?
I expect the
<tbody>
to be correctly rendered when using a variable in a<th>
inside<Table>
component wrapped in a another element (<figure>
, custom element, etc.).Link to Minimal Reproducible Example
https://stackblitz.com/edit/astro-table-th-figure?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: