Bug 228843

Summary: Implement auto-expanding details
Product: WebKit Reporter: Joey Arhar <jarhar>
Component: DOMAssignee: sideshowbarker <mike>
Status: NEW ---    
Severity: Normal CC: andresg_22, aroselli, bramus, cdumez, cfleizach, emilio, ggaren, jcraig, jhoffman23, kevin_neal, mike, nicolas, rik, steven, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Joey Arhar 2021-08-05 13:28:52 PDT
In this HTML spec PR, we are making <details> automatically expand for element fragments and find-in-page: https://github.com/whatwg/html/pull/6466
This way, the user can effectively use find-in-page to search for content hidden inside <details> elements without having to manually expand all of them first.
In order to make it performant, the spec PR also suggests using content-visibility:hidden inside <details>'s user agent shadowdom instead of "removing the slot from the rendering" when <details> are closed.
Comment 1 Radar WebKit Bug Importer 2021-08-12 10:41:39 PDT
<rdar://problem/81856620>
Comment 2 sideshowbarker 2023-10-06 14:32:50 PDT
Pull request: https://github.com/WebKit/WebKit/pull/18785
Comment 3 James Craig 2023-11-15 15:27:09 PST
Whoever works on this feature, please work with WebKit Accessibility DRIs to make sure it works with accessibility, such as VoiceOver navigation by heading (VO+Cmd+H), where heading is in a collapsed section. Or VoiceOver Find (VO+F)
Comment 4 sideshowbarker 2023-11-16 10:01:29 PST
(In reply to James Craig from comment #3)
> Whoever works on this feature, please work with WebKit Accessibility DRIs to
> make sure it works with accessibility, such as VoiceOver navigation by
> heading (VO+Cmd+H), where heading is in a collapsed section. Or VoiceOver
> Find (VO+F)

I have a PR ready for review at https://github.com/WebKit/WebKit/pull/18785. It doesn’t yet include any accessibility tests, and I’ve not yet done any manual testing of it myself with VoiceOver, but I’d love to get some guidance and review.
Comment 5 Tyler Wilcock 2023-12-20 15:33:56 PST
(In reply to sideshowbarker from comment #4)
> (In reply to James Craig from comment #3)
> > Whoever works on this feature, please work with WebKit Accessibility DRIs to
> > make sure it works with accessibility, such as VoiceOver navigation by
> > heading (VO+Cmd+H), where heading is in a collapsed section. Or VoiceOver
> > Find (VO+F)
> 
> I have a PR ready for review at https://github.com/WebKit/WebKit/pull/18785.
> It doesn’t yet include any accessibility tests, and I’ve not yet done any
> manual testing of it myself with VoiceOver, but I’d love to get some
> guidance and review.
VO-Cmd-H (find next heading) works via Accessibility::findMatchingObjects, which traverses the AX tree to try and find objects that match the given search key. AccessibilitySearchKey::Heading is one of many such keys. VO-F works similarly, searching the AX tree for the target AccessibilitySearchCriteria::searchText and comparing it against several different types of accessibility text.

Unfortunately, I don't think either will "just work" as the contents of collapsed details elements are not part of the AX tree (because they are not rendered, inherently excluding them). So we’ll need to do something special here.

Maybe we need to compute “collapsed descendants” for closed details element AX objects, which includes AX objects ignored only due to their lack of visibility / rendering. This collapsed descendants function would return early if the object’s role is not details, or if it is expanded.

Then we update `findMatchingObjects` to check an object’s collapsed descendants for matches. If a collapsed descendant is found to be a match, we’ll need to call `AXCoreObject::setIsExpanded(true)` on the containing details.

But this is pretty complicated, maybe there is some simpler solution here...not sure.