-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[url_launcher] Adds documentation that a launch needs to be triggered by a user action #5143
[url_launcher] Adds documentation that a launch needs to be triggered by a user action #5143
Conversation
@@ -37,6 +37,16 @@ import 'type_conversion.dart'; | |||
/// - "_self" opens the new URL in the current tab. | |||
/// Default behaviour when unset is to open the url in a new tab. | |||
/// | |||
/// Some web browsers, such as Safari, may prevent URL launching if it is not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I normally add these notes to the README of the web package under a "Limitations of the web platform" section (example, very similar to the Autoplay problem!), but I'm not sure if those are discoverable enough, since they're by default "hidden" in pub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree that it's a bit hidden and the README.md
would also a good place 👍 If you or @stuartmorgan like the approach with README.md
more, I could copy the structure of the video_player
package (having a short note that there are limitations on web in the main README and a more detailed description in url_launcher_web
package).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think putting the long explanation in the README and then referencing that here is probably the best option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the following changes:
- Adding a link about the web limitations in the "Configuration" section of the
README.md
ofurl_launcher
(likevideo_player
has), please let me know if this is the wrong location - Adding a new section "Limitations on the Web platform" with the detailed documentation in the
README.md
of theurl_launcher_web
package - Just referencing to this limitation in the
launchUrl
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me with nits, but @ditman should do the main review.
|
||
### A launch needs to be triggered by a user action | ||
|
||
Some web browsers, such as Safari, may prevent URL launching if it is not triggered by a user action (e.g. a button click). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We generally try to wrap our markdown files at about 80 characters; could you wrap all of these long lines?
|
||
Even if a user triggers a launch through a button click, if there is a delay due to awaiting a Future before the launch, the browser may still block it. This is because the browser might perceive the launch as not being a direct result of user interaction, particularly if the Future takes too long to complete. | ||
|
||
In such cases, you can use the `webOnlyWindowName` parameter, setting it to "_self", to open the URL within the current tab. Another approach is to ensure that the `uri` is synchronously ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is directly about the same thing as the previous text, so should not be a new paragraph.
@ditman I applied the suggestions by @stuartmorgan and resolved the merge conflicts 👍 It's ready for review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nilsreichardt, I left a few tweaks to the docs and a link to a relevant page of the MDN, lmk if my changes make sense to you. We can land this once you adopt those changes (or something similar). Important to say that this is definitely not a safari-only thing, all browsers are doing this.
packages/url_launcher/url_launcher/lib/src/url_launcher_uri.dart
Outdated
Show resolved
Hide resolved
Co-authored-by: David Iglesias <ditman@gmail.com>
Co-authored-by: David Iglesias <ditman@gmail.com>
Co-authored-by: David Iglesias <ditman@gmail.com>
Co-authored-by: David Iglesias <ditman@gmail.com>
Co-authored-by: David Iglesias <ditman@gmail.com>
@ditman Thanks for the suggestions ❤️ LGTM |
Thanks! I've restarted a couple of flaky checks, and will apply autosubmit. This should land today. |
…riggered by a user action (flutter/packages#5143)
flutter/packages@6cd0657...cb6dbcd 2023-12-09 stuartmorgan@google.com [multicast_dns] Adjust README (flutter/packages#5529) 2023-12-09 stuartmorgan@google.com [tool] Use ^ for Dart SDK (flutter/packages#5623) 2023-12-09 ditman@gmail.com [google_sign_in_web] Migrate to pkg:web. (flutter/packages#5612) 2023-12-08 stuartmorgan@google.com [google_maps_flutter] Disable failing iOS tests (flutter/packages#5629) 2023-12-08 43759233+kenzieschmoll@users.noreply.github.com Add `parse` constructors for the `BenchmarkResults` and `BenchmarkScore` classes (flutter/packages#5614) 2023-12-08 43054281+camsim99@users.noreply.github.com [path_provider_android] Disable `getExternalStorageDirectories (type: ...)` test (flutter/packages#5619) 2023-12-08 stuartmorgan@google.com [ci] Fix indentation in labeler.yml (flutter/packages#5625) 2023-12-08 102626803+drewroengoogle@users.noreply.github.com Update labeler to 5.0.0, fix yml format (flutter/packages#5580) 2023-12-08 me@nils.re [url_launcher] Adds documentation that a launch needs to be triggered by a user action (flutter/packages#5143) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
… by a user action (flutter#5143) Some web browsers, such as Safari, may prevent URL launching if it is not triggered by a user action (e.g. a button click). Even if a user triggers a launch through a button click, if there is a delay due to awaiting a Future before the launch, the browser may still block it. This can be confusing if you don't know it. As flutter/flutter#78524 suggested, should this be documented. Therefore, I added a few sentences to the `launchUrl`. Please let me know if this documentation is too long or not the right place. Fixes flutter/flutter#78524
… by a user action (flutter#5143) Some web browsers, such as Safari, may prevent URL launching if it is not triggered by a user action (e.g. a button click). Even if a user triggers a launch through a button click, if there is a delay due to awaiting a Future before the launch, the browser may still block it. This can be confusing if you don't know it. As flutter/flutter#78524 suggested, should this be documented. Therefore, I added a few sentences to the `launchUrl`. Please let me know if this documentation is too long or not the right place. Fixes flutter/flutter#78524
Some web browsers, such as Safari, may prevent URL launching if it is not triggered by a user action (e.g. a button click). Even if a user triggers a launch through a button click, if there is a delay due to awaiting a Future before the launch, the browser may still block it. This can be confusing if you don't know it. As flutter/flutter#78524 suggested, should this be documented. Therefore, I added a few sentences to the
launchUrl
.Please let me know if this documentation is too long or not the right place.
Fixes flutter/flutter#78524
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.