-
Notifications
You must be signed in to change notification settings - Fork 162
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
Clarify circumstances in which BeforeInstallPromptEvent.prompt() may be called #691
Comments
@mgiuca, I'm not at Samsung now. @poshaughnessy and @romandev may be able to answer or route the question. |
@dominickng and I worked out three distinct proposals we could apply to the spec (I'm referencing UA Options 1, 2, 3 and 4 from the "This gives UAs a couple of options" list above). Proposal 1Allow automatic prompt to be cancelled by Pros: Most flexible for user agents. Cons: If UA Option 4 is rare, developers may not know they have to call Proposal 2Completely detach BIP from automated prompt. Pros: Simple for developers and user agents. BIP is now fully misnamed, but at least it has clear semantics: it just controls manual prompting, which is unrelated to automatic prompting. This is the way we are heading with Chrome (with our minimalistic automatic prompt explorations; we are no longer tying that to BIP). Cons: UA has no option to show an intrusive automatic prompt which can be suppressed by the developer. Must design a minimalistic automatic prompt instead. Developers may be upset that they are unable to suppress the automatic prompt (but this is already the case with UA Option 3). Proposal 3
Pros: Most flexible for user agents, without the weirdness of UA Option 4's double prompting from Proposal 1. Cons: Use of ConclusionProposal 2 is the simplest with the least rough edges. We should do this, unless there are any UAs that really want to take Option 4 (a suppressible automatic prompt). |
@jungkees ah thanks for the heads up. |
Adding @andreasbovens who is PM on the Firefox PWA support |
From a quick reading, it seems indeed like proposal 2 is best here. Looping in @marcoscaceres for his take. |
From proposal 2:
Totally agree. As a web author, I started some tests after chrome post and I'm To me, UA components should not (automatically) invade webapp land. What is the downside of the option 1 (opt-in) ? |
We must carefully distinguish User Agent Options (the Options 1–4 above) and Spec Proposals (the Proposals 1–3 above). Here, we're just debating the spec proposals, which are three different ways we could go with the spec requirements, and then UAs would have (in any proposal) a number of Options available. @frlinw You're arguing for a particular UA option (1) but that's a debate you need to have with individual browser manufacturers (including me, on Chrome, but not here). We can't mandate a particular UI in the spec, only the requirements around the API. Note that all 3 Proposals allow both Options 1 (developer opt-in) and 2/3 (automated prompt not linked to We can't specify that browsers are not allowed to show an automated prompt not linked to the Now putting on my browser manufacturer hat (Chrome):
It's mainly that most sites aren't currently using |
I had the mini-infobar in mind but if it's a component in the UA land (Indeed, I saw it here), obviously it wont be an issue and the opt-in does not make sense. Just a last thing, I still don't understand how option 1 (opt-in) can be compatible with option 2 & 3 (auto) in Proposal 2. Is that mean the opt-in feature wont be described as a part of the spec but UA can implement it if they want ?
Proposal 2
|
It could be either. From a spec standpoint, certainly the infobar versus an icon in the address bar are the same (they're both non-page content so they're outside the realm where the spec can dictate UA behaviour).
The thing is that Chrome, at least, shows infobars "invading the content space" all the time, for many things which are not specced, and don't give developer control. For a few examples:
The infobar to install the app is fairly in-line with other parts of the Chrome UI and I believe all browsers have similar features. Having said that, we recognise that it's a bit heavy-handed to show this all the time so we're looking at more subtle UI.
Yeah, Proposal 2 just means that BeforeInstallPrompt is only used to control manual prompting, and isn't tied to automatic prompt at all. Thus:
Automatic prompts are purely a UA-specific feature which the spec says nothing about, normatively (contrary to the spec today which explicitly talks about automatic prompts). A UA could choose to never show an automatic prompt (Option 1) or to show one, but not tied to the BeforeInstallPrompt event (Option 2 or 3). |
Currently a few issues:
It doesn't call
preventDefault
, which means if you have a standards-compliant browser that shows an automated prompt, the above code works this way:beforeinstallprompt
event.beforeinstallprompt
event handler enables the "Install" button.prompt()
immediately resolves with the result of the automated install banner, without showing a second prompt.This is a bad user experience because they are left with an enabled, but ineffective Install button.
However, the above code runs perfectly well in a browser that does not use automated install prompts, such as Chrome.
Suggested changes:
prompt()
. (Are there any UAs that implementBeforeInstallPromptEvent.prompt()
that don't require a user gesture?)prompt()
from inside BIP would require the UA to show a second prompt, even if an automated one was already shown.prompt()
wouldn't just return the result of the previously-shown automated prompt. You would still be able to usepreventDefault
to cancel some automated prompts (see below). There would be no need to usepreventDefault
before callingprompt
, but sites may still wish to do this.This gives UAs a couple of options:
Edit: Updated the descriptions above to be clearer (based on text in the spec draft).
The above suggestion, I believe, will be compatible with Chrome and Firefox today, and avoid the awkward compat issue with any future browsers (or old versions of Chrome) highlighted above.
@jungkees does Samsung Browser behave in a way compatible with the described changes?
@dominickng @marcoscaceres @kenchris
(I can rework the described changes in the form of a pull request if it's unclear.)
The text was updated successfully, but these errors were encountered: