Allow explicit target for Linking.openURL(), default to "_blank" #2277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extends on the work started by @Sharcoux in PR #1743 and relates to issues #162, #1544, and #1744.
The desire of those tickets was to open
Linking.openURL(url)
in a new tab, and the solution merged by @necolas in this commit hard-codes the"_blank"
target to force a new tab. This is great for people who want new tabs, but inconvenient for people who want to use the same tab.This PR reworks the method to accept a second argument,
Linking.openURL(url, target)
for an explicit target. Any value passed will be used as the target, includingundefined
. The ability to pass undefined allows users to maintain the same browser tab, while arbitrary values allow... well, anything.For backwards compatibility, if
Linking.openURL(url)
is called without atarget
, the default value of"_blank"
will be passed. Therefore this change should have zero impact on any code already written, only users henceforth who explicitly pass atarget
will get the new behavior.Also, tests added!