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

Define focus behavior for <dialog> element with Shadow DOM #2393

Closed
TakayoshiKochi opened this issue Feb 24, 2017 · 12 comments · Fixed by #7285
Closed

Define focus behavior for <dialog> element with Shadow DOM #2393

TakayoshiKochi opened this issue Feb 24, 2017 · 12 comments · Fixed by #7285
Labels
topic: dialog The <dialog> element. topic: focus topic: shadow Relates to shadow trees (as defined in DOM)

Comments

@TakayoshiKochi
Copy link
Member

The dialog focusing steps algorithm doesn't define well about focusing behavior when Shadow DOM is involved.

See the context at crbug#383230.

@foolip
Copy link
Member

foolip commented Feb 24, 2017

On https://crbug.com/383230 I don't see any concrete suggestion of what the spec should do, except from comment 16 where it sounds like it's complicated. Spec prose aside, what is the most desired behavior here?

@hayatoito

@rniwa
Copy link

rniwa commented Feb 24, 2017

I really hope someone is writing WPT tests for dialog inside a shadow tree.

@foolip
Copy link
Member

foolip commented Feb 24, 2017

Tests will be needed to cover the eventual spec change, so that could be a good way to investigate current behavior and illustrate preferred behavior. (Such a PR would be left open until the spec change is reviewed.)

@danbeam
Copy link

danbeam commented Feb 24, 2017

i'd be happy to write a web platform test regarding the use of shadow DOM in <dialog> if we can come to consensus

@TakayoshiKochi
Copy link
Member Author

@danbeam that is more than welcome! As @foolip commented, such WPTs could fail with current Chrome implementation and should be what it would be specced. The serious usage experience of yours is valuable input for the spec change.

@hayatoito
Copy link
Member

hayatoito commented Feb 24, 2017

Ah, I have found this discussion: #1929
It is too long, and it is hard for me to figure out a progress there.

@danbeam Yeah, wpt would be highly appreciated to understand a desired behavior.

IMO, a sub tree of a dialog element and a document tree should not have any divergent behavior, regarding how focus works, e.g. how autofocus attribute works, or how sequential navigation (Tab-ing) works.
Shadow DOM is not an exception. In either cases, a shadow tree they have should be treated in the same way, as defined in http://w3c.github.io/webcomponents/spec/shadow/#focus, when to define autofocus-ed element or determine the next sequential focus navigated element.

We might also be interested in autofocus and Shadow DOM issue, #833, which has not got much attention recently.

@TakayoshiKochi
Copy link
Member Author

And #1175 seems an umbrella bug for Shadow DOM + <dialog> in general.

@tkent-google
Copy link
Contributor

We should simply change 'descendant' and 'tree order' in 'dialog focusing steps' to shadow-aware concepts, right?

Which one is preferable?

@tkent-google
Copy link
Contributor

tkent-google commented Sep 19, 2019

I found Chrome's 'dialog focusing steps' implementation already applied flat tree. Does anyone object to applying flat tree?

@domenic
Copy link
Member

domenic commented Sep 19, 2019

We should simply change 'descendant' and 'tree order' in 'dialog focusing steps' to shadow-aware concepts, right?

Right.

Which one is preferable?

Given that autofocus normally uses "inserted into a document" and thus doesn't pierce shadow trees (which I assume is working as intended?), we should probably not use shadow-including.

However, I'm unsure whether flat tree is the right choice here. Should we just use "normal" tree order?

/cc @annevk @smaug----

@domenic
Copy link
Member

domenic commented Sep 19, 2019

Given that autofocus normally uses "inserted into a document" and thus doesn't pierce shadow trees (which I assume is working as intended?)

I found #833 which contains some discussion on this point. It seems things are a bit more complicated.

Should we try to treat dialog as if it has delegatesFocus? Maybe solving this should be blocked on implementing the consensus from #833?

@tkent-google
Copy link
Contributor

Given that autofocus normally uses "inserted into a document" and thus doesn't pierce shadow trees (which I assume is working as intended?), we should probably not use shadow-including.

Ah, that's right. Searching shadow trees for autofocus in dialog.show() would be inconsistent.

Maybe solving this should be blocked on implementing the consensus from #833?

Yeah, we should have a consistent solution for this and #833.

@annevk annevk added the topic: dialog The <dialog> element. label May 29, 2020
@domenic domenic added the agenda+ To be discussed at a triage meeting label Aug 23, 2021
@past past removed the agenda+ To be discussed at a triage meeting label Sep 2, 2021
domenic added a commit that referenced this issue Nov 1, 2021
Closes #2393, by making <dialog> behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not.
domenic added a commit that referenced this issue Nov 2, 2021
Closes #2393, by making <dialog> behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not.
domenic added a commit that referenced this issue Nov 18, 2021
Closes #2393, by making <dialog> behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not.
dandclark pushed a commit to dandclark/html that referenced this issue Dec 4, 2021
Closes whatwg#2393, by making <dialog> behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not.
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
Closes whatwg#2393, by making <dialog> behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: dialog The <dialog> element. topic: focus topic: shadow Relates to shadow trees (as defined in DOM)
Development

Successfully merging a pull request may close this issue.

10 participants