-
Notifications
You must be signed in to change notification settings - Fork 3k
Add the interestfor
attribute
#11006
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
base: main
Are you sure you want to change the base?
Conversation
This is an initial translation of https://open-ui.org/components/interest-invokers.explainer/ to spec language, with a lot of things incomplete. @mfreed7 I think the two biggest points of uncertainty I have now are the integration with mouse/keyboard/touch input on the one end, and with CSS on the other. For showing interest, the timing of these algorithms relative to "mouseover" and other events needs to be defined. For CSS, the fact that there are CSS properties controlling the timing means we need to think about:
There are many more minor TODOs, but I'd like to get the high-level flow settled first. |
interesttarget
attribute
source
Outdated
|
||
<ul> | ||
<li><p>Actually invoke the capture/lose algorithms.</p></li> | ||
<li><p>Which algorithm reads the computed style for interest-target-delay?</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There need to be algorithms equivalent to these from Chromium code:
I think those three should hit most of the things in this list. Hopefully.
0aac997
to
9e40cb6
Compare
source
Outdated
<ul> | ||
<li><p><dfn export for="interest state" data-x="interest-state-none">none</dfn></p></li> | ||
|
||
<li><p><dfn export for="interest state" data-x="interest-state-partial">partial</dfn></p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfreed7 Chromium additionally has a "potential partial interest" state used for popovers:
Do we have to do the same in the spec? Or can we check if the target element is a popover when the scheduled task runs? The popover
attribute could be removed before the task runs, so checking it ahead of time seems like it adds the need to double-check it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you'll need this. It's used e.g. to add CSS for the "hint" text about the hotkey, and to check the conditions for moving from partial interest to full interest.
This happens when a user focuses an element that targets a popover which contains interactive content. In that situation, the popover is shown in "partial interest" mode, which renders the interactive content non-keyboard-focusable, so that they don't hijack the sequential focus navigation order. Then, hitting a keyboard hotkey, or doing other things like hovering the popover with the mouse, will upgrade it to "full interest".
Since all of the above doesn't happen if the target isn't a popover, you have to check twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Do we also need :has-potential-partial-interest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per other conversations, this whole thread is moot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I went through these fairly carefully and tried to provide links to Chromium code for the missing stuff. Hopefully that makes it a lot easier for you to find the equivalent code that we're trying to spec out.
source
Outdated
<p>The <dfn element-attr for="html-global"><code data-x="attr-interesttarget">interesttarget</code></dfn> | ||
attribute on <code>a</code>, <code>area</code>, and <code>button</code> elements allows authors to | ||
set up an invoker relationship between the triggering element and a separate target element such | ||
as a popover. With this arrangement, when the user shows interest in the triggering element (e.g., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that it'll pay off to define a concept for "showing interest" that you can refer to, e.g. in this sentence. That will eliminate "e.g. by hovering or focusing" wherever that appears. And another for "losing interest".
The definition of "showing interest" is loosely hovering the element with the mouse for longer than the delay, or focusing the element with the keyboard for longer than the delay, or long-pressing the element on a touchscreen. Whether it makes sense to define these in words, or just rely on the algorithms that practically say those same things, I leave to you. My preference would be to leave it to the algorithms.
Current Chromium code defines this cleanly in one spot, but as of the time of this comment, the code search cache hasn't updated to see it yet. But you can see the algorithms that essentially define interest for at least mouse and keyboard here.
This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e
This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1510373}
This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1510373}
This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1510373}
For anyone following only this PR and not the tracking issue, see #10309 (comment) about today's WHATNOT discussion and request to advance to stage 2. |
…hat have interest, a=testonly Automatic update from web-platform-tests Make ESC lose interest in all elements that have interest This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1510373} -- wpt-commits: d2c3a6825856a39ca05b811576676c4488ccf3e1 wpt-pr: 54668
…hat have interest, a=testonly Automatic update from web-platform-tests Make ESC lose interest in all elements that have interest This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <jarharchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1510373} -- wpt-commits: d2c3a6825856a39ca05b811576676c4488ccf3e1 wpt-pr: 54668 UltraBlame original commit: f1521afeb3e135fd1851d48adc6d81832028011b
…hat have interest, a=testonly Automatic update from web-platform-tests Make ESC lose interest in all elements that have interest This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <jarharchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1510373} -- wpt-commits: d2c3a6825856a39ca05b811576676c4488ccf3e1 wpt-pr: 54668 UltraBlame original commit: f1521afeb3e135fd1851d48adc6d81832028011b
…hat have interest, a=testonly Automatic update from web-platform-tests Make ESC lose interest in all elements that have interest This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <jarharchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1510373} -- wpt-commits: d2c3a6825856a39ca05b811576676c4488ccf3e1 wpt-pr: 54668 UltraBlame original commit: f1521afeb3e135fd1851d48adc6d81832028011b
…hat have interest, a=testonly Automatic update from web-platform-tests Make ESC lose interest in all elements that have interest This CL implements the behavior described in the spec PR: whatwg/html#11006 That is: the ESC key is handled very much like popovers - the focus doesn't need to be on the invoker for ESC to work. Also, hitting ESC loses interest in all elements that currently have interest, in reverse order. A test is added to confirm this. Note: I purposely did not use close watcher here, since I don't believe the close watcher stack should get involved. E.g. the android Back button should just navigate back, and not first lose interest in things. Closing a popover or modal dialog is different than a tooltip being open on a page. Bug: 326681249 Change-Id: I33cc2742a677f330d90b83c29b18b22bf49b716e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6900679 Reviewed-by: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1510373} -- wpt-commits: d2c3a6825856a39ca05b811576676c4488ccf3e1 wpt-pr: 54668
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, other than the flat tree comment you made.
…o that for all upstream interest sources on any "show" interest change
b5a12a7
to
fa121b6
Compare
fa121b6 is intended to align with https://chromium-review.googlesource.com/c/chromium/src/+/6970966. @mfreed7 can you carefully review it? It's now closer to the Chromium implementation in that it doesn't depend on a recursive call to "handle interest change", but there are differences that I'm unsure about:
|
Thank you!
This seems right. I removed that code from Chromium and the tests still pass. I'll land that change, but this seems ok as-is in spec.
Hmm, |
From the spec PR review here: - whatwg/html#11006 it became clear that this code was over-complicated. This simplifies it quite a bit, and retains the existing functionality. Bug: 326681249 Change-Id: Ie7027b9fdefd7fbf77e9d57aca89775902cc8ce6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7008933 Commit-Queue: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Reviewed-by: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1525802}
The
interestfor
attribute indicates that an element is an interestinvoker and points (via ID) at the element that should be invoked (made
visible, typically) when the user shows interest in the invoker. When
the target is a popover, it is automatically opened and closed as
interest is gained and lost. The delay before interest is gained or lost
can be customized using the
interest-delay-*
CSS properties.The typical use case for this is hovercards and tooltips.
Keyboards, pointing devices, and touch behavior is normatively defined, and the
user agent should provide a way for the user to express interest regardless of
input modality.
Based on https://open-ui.org/components/interest-invokers.explainer/ and
the implementation in Chromium.
The
:interest-source
and:interest-target
CSS pseudo-classes are defined here:https://drafts.csswg.org/selectors/#interest-pseudos
The
interest-delay-*
CSS properties are defined here:https://drafts.csswg.org/css-ui-4/#interest
(See WHATWG Working Mode: Changes for more details.)
/browsers.html ( diff )
/form-elements.html ( diff )
/image-maps.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/popover.html ( diff )
/semantics-other.html ( diff )
/text-level-semantics.html ( diff )
/interestfor.html ( diff )