You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiStat] Allow customizing the render of the title and description HTML tags #3676
The error occurs when in the Stat component in the description you add something other than plain text, for example I include my own component, doing this generates a <div> tag inside a <p>, for example:
<p><div></div></p>
This produces a problem with React validation, to be more exact it shows this warning in console:
Warning: validateDOMnesting (...): <div> cannot appear as a descendant of <p>.
Modifying the <p> tags by <span> fixes this error and so you can use custom components, even other Eui components within stats.
Regarding the error, I thought that might be the case. EuiStat is pretty prescriptive with the elements it renders because they're being wrapped in EuiTitle and EuiText components which should be some level of text element (heading, paragraph, etc).
We will need to support some level of customizing these elements instead of just replacing the <p> tags with <span> tags. It will require updating props, TS types, tests, and docs.
Action item:
Add props like titleElement and descriptionElement to EuiStat and allow any(?) string to render that html tag as, defaulting to p.
Activity
cchaos commentedon Jul 1, 2020
Regarding the error, I thought that might be the case. EuiStat is pretty prescriptive with the elements it renders because they're being wrapped in EuiTitle and EuiText components which should be some level of text element (heading, paragraph, etc).
We will need to support some level of customizing these elements instead of just replacing the
<p>tags with<span>tags. It will require updating props, TS types, tests, and docs.Action item:
Add props like
titleElementanddescriptionElementto EuiStat and allow any(?) string to render that html tag as, defaulting top.ashikmeerankutty commentedon Jul 1, 2020
If an element other than a
stringis provided. What could we do for the screen reader. When I provided a div it was showing [object Object]eui/src/components/stat/stat.tsx
Lines 139 to 141 in c19ca9f
shrey commentedon Jul 2, 2020
@cchaos The description just straight out displays the text written inside it, could you guide me as to how to reproduce the bug.
ashikmeerankutty commentedon Jul 2, 2020
Check the console for a warning
shrey commentedon Jul 2, 2020
Still no warning though
ashikmeerankutty commentedon Jul 2, 2020
You passed the component as
string. The component is not rendered here.Try this: