Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27522] WebView: onlink and beforeload are not consistent across platforms

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-12-10T16:18:09.000+0000
Affected Version/sRelease 8.2.1
Fix Version/sRelease 9.0.0
ComponentsiOS
LabelsengSchedule, parity
ReporterGiorgio Mandolini
AssigneeJan Vennemann
Created2019-10-24T15:30:33.000+0000
Updated2019-12-10T16:18:09.000+0000

Description

What happens: - on iOS both the onlink function and the beforeload event are called when setting html, while on Android this happens only for beforeload. - on iOS both the onlink function and the beforeload event are called also for embeds (like iframe) while on Android this not happen at all. This is causing me some trouble working on iOS because of "false positive" events that I need to distinguish as user clicks or normal page loading. I'd like to suggest a PR where *solution 1:* - iOS will send onlink only when navigation type is WKNavigationTypeLinkActivated - beforeload event will expose the isMainFrame indication to indicate if it was generated on the main page or an iframe. _or:_ *solution 2:* - iOS will send onlink only when navigation type is WKNavigationTypeLinkActivated - beforeload event is generated only if navigationAction.targetFrame.isMainFrame is true At the moment I've implemented in the PR the first solution, since iOS is already a little different from Android because it already exposes the platform specific attribute navigationType See the [PR](https://github.com/appcelerator/titanium_mobile/pull/11295)

Attachments

FileDateSize
app.js2019-10-24T15:20:23.000+00001019
logs.txt2019-10-24T15:21:58.000+00002850

Comments

  1. Joshua Quick 2019-10-24

    The "onlink" callback is only intended to be invoked when the end-user taps/click on a link. It's not supposed to be invoked when loading a page via the "url"/"html" properties or when navigation programmatically via the HTML's own JavaScript code. If this is the behavior that you are seeing on iOS, then the native iOS code needs to be changed to match Android's behavior. (Android can't replicate iOS' WebView behavior in this case anyways.)
  2. Giorgio Mandolini 2019-10-25

    Thanks for the clarification Joshua, actually the iOS webview calls the onlink callback too many times (details on logs), so it would be better to implement the solution #1 and stop iOS to send events when they are not user generated.
  3. Joshua Quick 2019-11-06

    [~gmandolini]'s PR can be found here: https://github.com/appcelerator/titanium_mobile/pull/11295
  4. Satyam Sekhri 2019-11-27

    FR Passed. Webview onLink is not called along with beforeLoad when setting html. It is fired when a link in the html is clicked and the link is being navigated.
  5. Satyam Sekhri 2019-11-27

    Waiting for Jenkins build to pass
  6. Lokesh Choudhary 2019-12-04

    PR Merged.
  7. Sohail Saddique 2019-12-10

    Fix verified on build: 9.0.0.v20191209135132. onlink does not fire unnecessarily unless by manual user navigation. Ticket closed.

JSON Source