Skip to content

[selectors] :user-interacted pseudo-class to match controls the user has interacted with #11065

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

Open
LeaVerou opened this issue Oct 22, 2024 · 4 comments
Labels

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Oct 22, 2024

A while back, we resolved to add :user-valid and :user-invalid pseudo-classes to represent :valid and :invalid states the user has interacted with.

These depend on a user has interacted state that is not exposed in any other way. I propose exposing it as a separate pseudo-class, then these become aliases of :user-interacted:valid / :user-interacted:invalid.

This came up in defining how custom element authors expose this state for their custom elements, but the pseudo-class seems useful in its own right, and if browsers are already tracking this state, it should be fairly low effort to implement.

(Name obviously TBB)

@Loirooriol
Copy link
Contributor

Would :user-interacted be the same as :is(:user-valid, :user-invalid)? Or are there things that the user can interact with but lack data validity semantics? Like expanding a <details> or something.

@LeaVerou
Copy link
Member Author

The latter.

@Loirooriol
Copy link
Contributor

Loirooriol commented Oct 24, 2024

That seems more useful but needs more thought about what exactly is considered to be an interaction. E.g. does selecting text or clicking in a normal <div> mark it as interacted? Browsers may be tracking some cases but not others, and if they don't agree about what to track, then it will be more effort to implement.

@LeaVerou
Copy link
Member Author

That seems more useful but needs more thought about what exactly is considered to be an interaction. E.g. does selecting text or clicking in a normal <div> mark it as interacted? Browsers may be tracking some cases but not others, and if they don't agree about what to track, then it will be more effort to implement.

I think it's reasonable to limit to focusable elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants