A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

[Proposal] Back Button Media Query

dntbrsnbl
2019-08-09

This API is being proposed as a way to eliminate the “double back button” problem (seen here, on Twitters PWA in the Microsoft store). This problem arises because developers of "standalone" , "fullscreen" , and "minimal-ui" apps have no way of determining whether a back button will be provided by the user agent (the browser, OS, or hardware), and so, are forced to implement their own, to ensure that their app is functional without the browser’s UI.

This will allow apps to avoid the “double back button” problem by letting them conditionally display a back button depending on whether the user agent is already displaying one. Adding a standard way to detect this means that we can avoid user-agent and viewport-size workarounds, which are not ideal for web compatibility.

More detail is available in the explainer

dntbrsnbl
2019-08-09

Note: Microsoft has expressed interest in experimenting with this API https://github.com/fallaciousreasoning/backbutton-mediaquery/issues/4

vincentriemer
2019-08-09

I’m not necessarily opposed to this, but couldn’t an alternative solution be some way to tell the user agent that it doesn’t need to render a back button if the app has its own?

dntbrsnbl
2019-08-09

I think this is part of a solution. Generally, we prefer not to tell browsers how their UI should look, so a spec for requesting buttons would probably say that a browser SHOULD show/hide a button, rather than that they MUST show/hide a button. In this case, I think the media query would still be useful to let sites know if the browser has respected their request.

We are considering an API like the one you describe (perhaps declaring buttons in the manifest) but we haven’t put together an explainer :).

frivoal
2019-08-09

This looks like a reasonable proposal to me. As a co-editor of Media Queries, I would encourage you to raise this as an issue against the specification, at https://github.com/w3c/csswg-drafts/issues.

(No strong opinion either way from me on the API)

dntbrsnbl
2019-08-12

Cool, I’ve created https://github.com/w3c/csswg-drafts/issues/4187 :slight_smile: