Skip to content

[EuiAccordion] HTML5 validity in buttonContent #4413

Closed

Description

@MichaelMarcialis

In a recent Kibana PR review, I noticed that an engineer was using a lot of non-phrasing HTML content (div and p elements in this case) in the buttonContent prop of an EuiAccordion component. Such usage would render invalid HTML5, as non-phrasing content is not allowed in a button element.

My initial instinct was to recommend that the engineer change their buttonContent, but I then noticed that our own EUI docs showcase a similar use of EuiAccordion that would also render invalid HTML5. Should the docs be updated to discourage such invalid usage of HTML5?

image

Additionally, it appears that the EuiText component that engineers would need to utilize in order to customize the text within the accordion button doesn’t offer any alternative to its current div wrapper. Should we offer an alternative EuiText wrapper element for areas where only phrasing content is allowed?

Activity

  1. cchaos commented on Jan 5, 2021

    @cchaos
    Contributor

    I'll def agree that our examples aren't ideal. A solution on the consuming (Kibana) side is just to recreate a layout with custom elements (<span>s) and custom classes applying the necessary flex layout and if needed, use the Sass mixins for font adjustments.

    Eventually we may get to a place where it's easy for us to allow different rendered elements, but you'll even find that rendering a <p> inside of a <button> is invalid as well.

    The other option would be having to be able to not render a <button> at all and put a onClick handler on a <div> but that comes with accessibility consequences.

  2. myasonik commented on Jan 5, 2021

    @myasonik
    Contributor

    On the a11y front, though this fails validators I'm not aware of any practical problems with it so I personally feel like dealing with it is pretty low priority.

    The worst a11y issues around this that I can think of are:

    • automated a11y testing solutions will sometimes flag it as an issue which can just be annoying to deal with
    • everything inside a button is strictly flattened into buttonContent so devs may be thinking that they're creating a button around some structured text but really it's all just a single string (while this one could be an issue we see, changing everything from div to span won't fix it and is more so an education problem)
  3. snide commented on Jan 6, 2021

    @snide
    Contributor

    On the a11y front, though this fails validators I'm not aware of any practical problems with it so I personally feel like dealing with it is pretty low priority.

    Agree with this. Prefer having the practical a11y working with a button and care less about the HTML validation errors (which browsers complain about, but don't tend to effect users).

  4. MichaelMarcialis commented on Jan 6, 2021

    @MichaelMarcialis
    ContributorAuthor

    Thanks for those thoughts, everyone. In general, I agree with you all that this is a low priority, especially considering the minimal a11y concerns. To clarify, I wasn't suggesting that we just change EuiText's wrapper to a span and calling it a day. I think the most important change would be to consider updating the EUI docs to show examples that yield valid HTML output. We could then also consider additional changes (such as the EuiText example, how EuiAccordion is structured, etc.).

    That said, is it worth keeping this issue open as a low priority? Or should I close it for the time being?

  5. cchaos commented on Feb 16, 2021

    @cchaos
    Contributor

    I think the problem is further reaching than just changing EuiText's rendered component to a <span> since EuiText styles target specific text elements like <p> and heading tags. So you'd still get invalid warnings. We could add a callout warning to that specific docs example, but I don't think there's actually any practical way to solve this without just removing the example entirely.

  6. github-actions commented on Aug 16, 2021

    @github-actions

    👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

  7. added
    stale-issue
    on Aug 16, 2021
  8. github-actions commented on Aug 23, 2021

    @github-actions

    ❌ We're automatically closing this issue due to lack of activity. Please comment if you feel this was done in error.

  9. added
    stale-issue-closed
    on Aug 23, 2021
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

    stale-issuestale-issue-closed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions