Skip to content

autofocus + delegateFocus handling doesn't make much sense to me #8156

Closed

Description

@emilio

So, looking at https://html.spec.whatwg.org/#focus-processing-model I have a couple questions:

If focus target is a shadow host whose shadow root's delegates focus is true

  1. [ snip ]
  2. Return the focus delegate for focus target given focus trigger.

Where https://html.spec.whatwg.org/#focus-delegate iterates over descendants of focus target for autofocus. That doesn't seem intentional?

In particular, per spec, document.querySelector(".focus-me").focus() behaves differently in these two examples, unless I'm misreading something:

<!doctype html>
<div class="focus-me">
  <button autofocus></button> <!-- doesn't get focused -->
</div>
<!doctype html>
<div class="focus-me">
  <button autofocus></button> <!-- gets focused -->
</div>
<script>
  document.querySelector(".focus-me").attachShadow({ mode: "open", delegatesFocus: true }).innerHTML = `<slot></slot>`;
</script>

It seems like step 2 might want to be "Return the focus delegate for focus target's shadow root given focus trigger.", rather than the current thing? That'd make way more sense to me, and seems to more closely match what implementations actually do.

cc @sefeng211 @domenic

Activity

  1. added
    topic: focus
    agenda+
    on Aug 4, 2022
  2. changed the title [-]autfocus + delegateFocus handling doesn't make much sense to me[/-] [+]autofocus + delegateFocus handling doesn't make much sense to me[/+] on Aug 4, 2022
  3. added a commit that references this issue on Aug 9, 2022
    a93d242
  4. removed
    agenda+
    on Aug 18, 2022
  5. added a commit that references this issue on Oct 22, 2022
    4d6609f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: focus

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions