Re: [w3c/manifest] Clarify circumstances in which BeforeInstallPromptEvent.prompt() may be called (#691)

@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 1

Allow automatic prompt to be cancelled by `preventDefault`. But `prompt` can show a second prompt, after the automatic prompt completes. This is what I propose above, and implemented in #692. This allows UAs to choose between Options 1, 2, 3 and 4 above.

Pros: Most flexible for user agents. `preventDefault` still works in UA Option 4, but not in UA Option 3. Developers who forget to call `preventDefault` will still have a functional Install button in all UAs that fire BeforeInstallPrompt (UA Options 1, 3 and 4).

Cons: If UA Option 4 is rare, developers may not know they have to call `preventDefault` to suppress the automated install prompt, which may be more intrusive in UA Option 4 because it's preventable. `preventDefault` may or may not work.

## Proposal 2

Completely detach BIP from automated prompt. `preventDefault` does nothing (BIP is no longer cancellable). Automated prompt cannot be suppressed by developer (it is simply considered part of the browser UI). This allows UAs to choose between Options 1, 2 and 3 above. Developers do not need to call `preventDefault`.

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

`preventDefault` is required before using `prompt` (even if there is no automatic prompt). UA Option 4 is now a choice of auto or manual (you can't have both).

Pros: Most flexible for user agents, without the weirdness of UA Option 4's double prompting from Proposal 1.

Cons: Use of `prompt` requires a superfluous call to `preventDefault` which may not make sense in UA Options 1 and 3 (confusing developer experience), especially since no known UAs will take Option 4. Essentially, for legacy reasons.

## Conclusion

Proposal 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).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/691#issuecomment-397180002

Received on Thursday, 14 June 2018 05:57:29 UTC