RESOLVED FIXED Bug 261621
formAssociated=true causes custom element to become focusable
https://bugs.webkit.org/show_bug.cgi?id=261621
Summary formAssociated=true causes custom element to become focusable
James Tu
Reported 2023-09-15 14:23:56 PDT
Created attachment 467691 [details] Repro When enabling formAssociated on a custom element, it becomes focusable whereas when formAssociated is false it is not. Chrome and Firefox both do not exhibit this behavior but it does occur in Safari Technology Preview Release 178 (Safari 17.0, WebKit 18617.1.6). When setting formAssociated=false Safari behaves the same as Chrome and Firefox. Attached is a repro showing that calling element.focus() with formAssociated=true causes focus to move to the element, which is demonstrated by document.activeElement below. customElements.define( 'x-foo', class Foo extends HTMLElement { static formAssociated = true; } ); const foo = document.querySelector('x-foo'); foo.focus(); console.log(document.activeElement); Note document.activeElement is <body> in Chrome and Firefox but <x-foo> in Safari. Note that the spec does not imply any kind of focus behavior for formAssociated: https://html.spec.whatwg.org/multipage/custom-elements.html#form-associated-custom-elements
Attachments
Repro (364 bytes, text/html)
2023-09-15 14:23 PDT, James Tu
no flags
Radar WebKit Bug Importer
Comment 1 2023-09-22 14:24:23 PDT
sideshowbarker
Comment 2 2023-10-02 00:19:50 PDT
sideshowbarker
Comment 3 2023-10-02 10:02:16 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/42287
EWS
Comment 4 2023-10-02 16:20:53 PDT
Committed 268756@main (7e0cd07bab81): <https://commits.webkit.org/268756@main> Reviewed commits have been landed. Closing PR #18487 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.