Bug 258682

Summary: Broken autofocus with popover custom element
Product: WebKit Reporter: Jeroen Zwartepoorte <jeroen.zwartepoorte>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bfulgham, ntim, rbuis, rniwa, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   

Description Jeroen Zwartepoorte 2023-06-29 09:49:37 PDT
https://codepen.io/jpzwarte/pen/abQJgeo

The above codepen has 4 examples of popover usage:
1. <div popover> with <button autofocus> inside it
2. <dialog popover> with <button autofocus> inside it
3. <x-popover> custom element with delegatesFocus: true and <button autofocus> in the shadow root
4. <x-popover> custom element with delegatesFocus: true and <button autofocus> slotted

1, 2 and 4 work fine in STP 173 (4 is broken in Chrome 114 and Chrome Dev 116)

3 is broken in STP 173 (works fine in Chrome).

I expect the <button> in <x-popover> to have focus when the popover is displayed. It hasn't. 
It is unclear what does have focus though. The original <button popovertarget> button is not it.
Comment 1 Jeroen Zwartepoorte 2023-06-29 10:04:57 PDT
The bug in the Chromium implementation: https://bugs.chromium.org/p/chromium/issues/detail?id=1459293
Comment 2 Rob Buis 2023-06-30 08:53:11 PDT
I am not sure the expectation that the focus enters the shadow tree is correct. The WPT test for it does not currently expect that:
https://github.com/web-platform-tests/wpt/blob/92454230c3/html/semantics/popovers/popover-shadowhost-focus.html
Comment 3 Radar WebKit Bug Importer 2023-07-06 09:50:18 PDT
<rdar://problem/111854670>