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

Interactions between inert and hidden="until-found" and beforematch events #10583

Closed
romainmenke opened this issue Aug 28, 2024 · 10 comments
Closed
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. clarification Standard could be clearer

Comments

@romainmenke
Copy link

romainmenke commented Aug 28, 2024

What is the issue with the HTML Standard?

Chrome is the only browser supporting all three features (as far as I know).

And up until Chrome 123 it was possible to set an element to inert, visually hide it with hidden="until-found".
We could then reveal it and make it non-inert through a beforematch event listener.

This was really handy to make accordions as the closed panels should be inert but we still want users to be able to search for text in a page and that the panel is opened and scrolled to when there is a match.

In Chrome 124 this stopped working.

When reading through the spec text for inert it doesn't specifically say that an element should not be findable through search in a page.

So I am not sure if this is a browser bug, or something that never should have worked in the first place and was actually fixed in Chrome 124.

Happy to file browser bugs if this is an issue in Chrome, but wanted to know the actual expected behavior first.

@romainmenke romainmenke changed the title Interactions between inert and hidden="until-found" and beforematch` events Interactions between inert and hidden="until-found" and beforematch events Aug 28, 2024
@josepharhar
Copy link
Contributor

Are you revealing it with find in page? Because we recently made find in page stop finding results in inert subtrees.

@romainmenke
Copy link
Author

Indeed, this used to work perfectly and inert is what we want.
So we shipped this in dozens of sites :/

As I said, I am unsure if this was ever supposed to work.
Specs don't seem te explicitly say anything about this and both behaviors could be argued for.

@annevk
Copy link
Member

annevk commented Oct 7, 2024

Do other browsers find text in (non-hidden) inert subtrees? This should probably be clarified in the standard if nothing is said about it today, though we can at most make this a "should" I suppose.

@annevk annevk added the clarification Standard could be clearer label Oct 7, 2024
@romainmenke
Copy link
Author

romainmenke commented Oct 7, 2024

  • Safari (latest) ✅
  • Chrome worked in 102 - 123, no longer works
  • Firefox worked in 112 - 123, no longer works

(weirdly coincidental that this stopped working both in 123)
(lower bound is when those browsers shipped inert)


Are there cases where you want an element to be visible, yet inert and not have it appear through "find in page"?

@annevk annevk added the a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. label Oct 7, 2024
@annevk
Copy link
Member

annevk commented Oct 7, 2024

I'm not sure, but it seems a bit suspect and might be an issue for keyboard-only users? cc @whatwg/a11y

@romainmenke
Copy link
Author

I agree that it is be bad for keyboard-only users when they find content that remains inert even after discovery.

@romainmenke
Copy link
Author

romainmenke commented Oct 7, 2024

I've investigated a bit further on how we ended up having both inert and hidden on the same elements as this also seemed weird to me.

We started out with panels that were hidden without using the hidden attribute or display: none; so that panel contents could be revealed with animations/transitions.

We used inert to ensure that panel contents were hidden from tab order, accessibility tree, ...

When hidden=until-found and beforematch were added to Chrome we added support, but we didn't revisit our whole implementation.

I think that for our specific case it makes more sense to remove inert altogether. hidden serves the same purpose for our use case.
Animating from hidden can now be done with @starting-style.


I think that the spec should clarify that inert elements are not discoverable through find in page and that Safari should be updated to match Chrome and Firefox.

@romainmenke
Copy link
Author

the spec should clarify that inert elements are not discoverable through find in page

https://html.spec.whatwg.org/#inert-subtrees

The user agent should ignore the node for the purposes of find-in-page.

Already in the spec :)


So to circle back to my original question which was specifically about beforematch event.

Removing inert through beforematch only worked because browsers weren't following the spec for inert and find in page.

So maybe this can be closed as "no change"?

@josepharhar
Copy link
Contributor

So maybe this can be closed as "no change"?

Sounds good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. clarification Standard could be clearer
Development

No branches or pull requests

3 participants