Skip to content

Allow strings for EuiToolTip children #2292

Closed

Description

@smith

The type for the children prop of EuiTooltip is React.ReactElement<any>. It expects this because it does a React.cloneElement to create the anchor.

Because it is of this type and not React.ReactNode, you cannot pass a string as children to a tooltip, so:

<EuiToolTip>{someValue}</EuiToolTip>

has to become:

<EuiToolTip><>{someValue}</></EuiTooltip>

It would be nice if we were more flexible and allowed any React.ReactNode as children.

Activity

  1. thompsongl commented on Sep 5, 2019

    @thompsongl
    Contributor

    I agree that React.ReactElement<any> is likely too strict. We do, however, need to consider a11y, so tab focus and keyboard navigation/interaction are a consideration and bare text is likely not an option. EUI could make assumptions about what to do with a string (e.g., wrap it in an EuiLink), but it'd have to be discussed.

  2. added
    design decision
    on Sep 5, 2019
  3. smith commented on Sep 5, 2019

    @smith
    ContributorAuthor

    I don't think we need to sacrifice the developer experience for accessibility; we can have both. I started to just open a PR to fix it but realized there were design considerations that were needed. Thanks for looking!

  4. cchaos commented on Mar 18, 2020

    @cchaos
    Contributor

    @smith Do you still hav that PR handy, we can certainly help with the design considerations.

  5. smith commented on Mar 18, 2020

    @smith
    ContributorAuthor

    @cchaos No I checked on the branch and there's nothing there, so I don't think I made any changes back then. Thanks for looking!

  6. changed the title [-]Allow strings for ToolTip children[/-] [+]Allow strings for EuiToolTip children[/+] on Mar 27, 2020
  7. cchaos commented on Sep 18, 2020

    @cchaos
    Contributor

    Related #4040 & #2027

  8. cchaos commented on Sep 18, 2020

    @cchaos
    Contributor

    Closing in favor of a Meta discussion around EuiTooltip flexibility which I've included a link to this discussion but needs to be a part of a greater effort.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    design decision

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions