Skip to content

EuiStat change tags to use components inside.#3673

Closed
victorst79 wants to merge 1 commit intoelastic:masterfrom
victorst79:master
Closed

EuiStat change tags to use components inside.#3673
victorst79 wants to merge 1 commit intoelastic:masterfrom
victorst79:master

Conversation

@victorst79
Copy link
Copy Markdown

@victorst79 victorst79 commented Jun 30, 2020

Summary

Hi guys!
With this PR a modification is made to the EuiStat component. When rendering title and description it was done as a "p" tag this caused an error if you work with any component within it.
With these changes you can already include Eui components or custom components within Stat.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link
Copy Markdown

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link
Copy Markdown

cla-checker-service Bot commented Jun 30, 2020

💚 CLA has been signed

@victorst79 victorst79 changed the title change tag in euistat EuiStat change tags to use components inside. Jun 30, 2020
@cchaos
Copy link
Copy Markdown
Contributor

cchaos commented Jun 30, 2020

Welcome @victorst79!
Would you please sign the CLA linked below. Be sure to use the same email address linked to your Github account.
I'll get our CI (Jenkins, test this) started for you which will run our tests and get a preview built.

Can you also explain further the error you would receive?

@victorst79
Copy link
Copy Markdown
Author

victorst79 commented Jun 30, 2020

Hi @cchaos !

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.

In reference to the CLA signature, I have signed it, I have downloaded the copy but it still marks the bot with a cross, is there any step that I have not done correctly?

Regards!

@cchaos
Copy link
Copy Markdown
Contributor

cchaos commented Jun 30, 2020

Sorry about the CLA comment, yes it is showing as complete. Github may not have refreshed. That's all good!

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).

EuiStat does accept children that aren't wrapped in any element. Would this suit your use-case?

If not, we will need to support some level of customizing these elements instead of just replacing the <p> tags with <span> tags. Is this something you'd like to take on, otherwise we can try to get someone to make these updates. It will require updating props, TS types, tests, and docs.

@victorst79
Copy link
Copy Markdown
Author

Hi @cchaos 👋

To put you in context, my problem is that within EuiStat I have a custom component that contains several text strings that allow me to filter directly with this information. It is a brief summary because it is a little complex to explain, my apologies.

In another order of things, I am not really good with unit tests, if you value my idea as positive and finally add it I would value it a lot.

Have a nice day!
Regards

@cchaos
Copy link
Copy Markdown
Contributor

cchaos commented Jul 1, 2020

We definitely value your idea @victorgs ! We'll just need to be sure we can be even more customizable with what element renders without possibly breaking any current implementations. What I'll do is create an issue for this, but close the current PR. Hopefully one of us or another community member can pick up the issue relatively soon for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants