Bug 258682 - Broken autofocus with popover custom element
Summary: Broken autofocus with popover custom element
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-06-29 09:49 PDT by Jeroen Zwartepoorte
Modified: 2023-07-06 09:50 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>