open-ui icon indicating copy to clipboard operation
open-ui copied to clipboard

`<summary for>` pointing to a `<details>` element elsewhere

Open LeaVerou opened this issue 2 years ago • 7 comments
trafficstars

Since we're on to making simple improvements to <details>, how about this: a for attribute on <summary> which can point to a <details> element by id, allowing them to be in entirely separate parts of the DOM. This would address the common author need to have toggles in separate places from the toggled content, is pretty straightforward in terms of syntax, and follows established markup patterns.

LeaVerou avatar Aug 25 '23 00:08 LeaVerou

Not saying this is better but a potential alternative to using for would be to use invokertarget from https://github.com/whatwg/html/issues/9625

lukewarlow avatar Aug 29 '23 01:08 lukewarlow

This just seems like a collapse/expand button to show arbitrary content, rather than as an accordion. Meaning that authors would probably misuse this.

Also, even with custom versions of an accordion, the button which expands the accordion is always close to the expanded text. So I don't think that this is needed.

YummyBacon5 avatar Aug 29 '23 11:08 YummyBacon5

I think it's worth considering whether https://github.com/openui/open-ui/issues/812#issuecomment-1692360733 by @aardrian applies here as well; I suspect it does, though I'm not sure.

dbaron avatar Aug 29 '23 13:08 dbaron

i could see this getting rather messy with details/summary specifically, especially regarding the fact that a details will automatically insert a summary within it if an author has not specified one. (there's a rabbit hole of what ifs related to this)

Not opposed to the idea of having a control that can toggle the visibility of other content in the page, re: https://github.com/openui/open-ui/issues/700 and the linked WHATWG issue that Luke referenced. But I'd definitely think those are the way forward here, rather than extending the summary element further - esp. with the accessibility issues that still need to be worked out with that element, and how this would just add onto that existing todo list.

scottaohara avatar Aug 29 '23 14:08 scottaohara

My gut reaction here, before even getting into how to handle missing <summary> in the case of typos / errors, is focus and reading order management. These elements are useful because they do not require the author to do that and this model would need to address that in detail with rules for failures to do so.

Wrapper element already fits existing patterns.

aardrian avatar Aug 29 '23 14:08 aardrian

There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.

github-actions[bot] avatar Feb 26 '24 00:02 github-actions[bot]