question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-nested-interactive Rejects Elements in <details> Body

See original GitHub issue

The no-nested-interactive lint check rejects the following structure

<details>
  <summary>Click to expand</summary>
  If you <button>click here</button> something will happen.
</details>

with a Do not use <button> inside <details> no-nested-interactive error.

This seems like a perfectly reasonable HTML structure to me. Per MDN on the <details> element:

A disclosure widget is typically presented onscreen using a small triangle which rotates (or twists) to indicate open/closed status, with a label next to the triangle. If the first child of the <details> element is a <summary>, the contents of the <summary> element are used as the label for the disclosure widget… A <details> widget can be in one of two states. The default closed state displays only the triangle and the label inside <summary> (or a user agent-defined default string if no <summary>)… When the user clicks on the widget, or focuses it then presses the space bar, it “twists” open, revealing its contents.

And it specifies permitted content as “One <summary> element followed by flow content” without excluding interactive content.

A <details> element should not appear inside another interactive element and interactive elements shouldn’t appear inside the <summary> element, but the body of an expanded <details> is not interactive and interactive elements inside a <details> behave as they would in a regular <div>.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Dec 13, 2019

I think we need to test this in practice with one or two screen readers to see what they actually do. I still think that I would expect the detail itself to be allowed to have interactive content, so I’d like to see if they do actually break / do a bad thing.

0reactions
MelSumnercommented, Aug 10, 2020

Following up- I’m going to close the issue since the behavior is technically correct- no-nested-interactive rule should reject interactive elements inside of a <details> element.

More reading:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested interactive controls are not announced by screen ...
Focusable elements with an interactive control ancestor (any element that accepts user input such as button or anchor elements) are not announced by...
Read more >
4.11 Interactive elements — HTML 5 - W3C
Interactive content. ... The details element is not appropriate for footnotes. ... It is used by user agents to display nested menus in...
Read more >
Focusing nested interactive elements with VoiceOver - CodePen
In this example, the VoiceOver cursor is moved to the div, because it does not contain a nested focusable element. It is also...
Read more >
9 Using Triggers - Oracle Help Center
For example, do not define triggers to reject bad data if you can do the same ... These triggers provide a way of...
Read more >
Bar Charts | Google Developers
Note: Material Charts will not work in old versions of Internet Explorer. ... data elements (such as values displayed with each bar on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found