speced/bikeshed

Support definitions in details > summary

inexorabletash opened this issue · 0 comments

The WebNN spec is trying out styling algorithms (abstract and for methods) using the <details> element like so:

<details open algorithm>
   <summary>To <dfn>foo</dfn> given |bar|:</summary>
   1. Do something to |bar|.
 </details>

This is usually rendered with a disclosure widget and when that or the summary is clicked on the open state toggles. The problem is that clicking on parts of the definition itself ("foo" and "bar" above) do things - the definition shows the info panel with references, the variables highlight usages within the algorithm. This works... but simultaneously toggles the open state. 🤮

Peeking at Bikeshed's code, clicks on <dfn>s call stopPropagation() but not preventDefault(). I experimented with adding a listener on summary dfn, summary var that calls preventDefault() and this gives my desired behavior. This is tangentially related to #2647.

(FWIW, I'm not personally a fan of using <details> for algorithms, but this seems fairly harmless to support in Bikeshed.)