Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
emilio opened this issue Aug 4, 2022 · 0 comments · Fixed by #8174
Closed

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

emilio opened this issue Aug 4, 2022 · 0 comments · Fixed by #8174

Comments

@emilio
Copy link
Contributor

emilio commented Aug 4, 2022

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

@emilio emilio added topic: focus agenda+ To be discussed at a triage meeting labels Aug 4, 2022
@smaug---- smaug---- changed the title autfocus + delegateFocus handling doesn't make much sense to me autofocus + delegateFocus handling doesn't make much sense to me Aug 4, 2022
domenic added a commit that referenced this issue Aug 9, 2022
@past past removed the agenda+ To be discussed at a triage meeting label Aug 18, 2022
domenic added a commit that referenced this issue Oct 22, 2022
Fixes #8156. Fixes #8157.

See also previous work in #7361, #7284, and #7079.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants