Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10584] Android: WebView click event is not being fired

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-06-21T07:16:32.000+0000
Affected Version/sRelease 2.1.1
Fix Version/sRelease 3.0.0, Sprint 2012-18 API
ComponentsAndroid
Labelsapi, module_webview, parity, qe-testadded, regression
ReporterNikhil Sharma
AssigneeKarl Rowley
Created2012-08-23T18:03:42.000+0000
Updated2019-07-18T13:11:22.000+0000

Description

Webview click event is not being fired when the parent window also has a click event. There is a change of behavior, it works fine in iOS. It used to work for android in Ti SDK 2.0.2.GA

Repo Steps

1. Run the below code in your app.js 2. Tap the "Click me" link and click event is not being fired.
var window = Titanium.UI.createWindow();

window.addEventListener('click', function(e) {
	Ti.API.info("************** e.y = " + e.y);
    if(e.y >= -20 && e.y < 13) {
        alert('Clicks on window object, scrolls content to top');
    } 
})
Titanium.App.addEventListener('openImage', function (e) {
    alert('Opening image');
});

var webView = Titanium.UI.createWebView();
var html = '<html>' + 
   '<body>' +
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<a onclick="javascript:alert(123456)">Click me!</a>' +
   '</body>' + 
   '</html>';
webView.html = html;
window.add(webView);
window.open();

Comments

  1. Ping Wang 2012-08-27

    In the original test case, when we tap the "click me" link, the "click" event is fired from the window. If we check the log console, we can see the output like:
       I/TiAPI   (20559):  ************** e.y = 176.55079650878906
       
    Seems the "click" event is bubbled up to the window on Android but it is not bubbled on iOS. If you remove the "click" event listener from the window, the link will work fine. BTW, the "click" event listener on webview does not work on 2.0.2GA and we fixed that for 2.1.0 (TIMOB-2017). That's why you see the different behaviors.
  2. Karl Rowley 2012-08-30

    Pull request https://github.com/appcelerator/titanium_mobile/pull/2853
  3. Rima Umbrasas 2012-09-05

    Tested as fixed: Titanium SDK, version 2.2.0.v20120904103252 Titanium Studio, build: 2.1.2.201208301612 Devices: iPone4 version 5.0.1 Nexus Android tablet version 4.1.1
  4. Priya Agarwal 2013-06-21

    Reopening just to update label.
  5. Priya Agarwal 2013-06-21

    Updated label and verified. Tested on: Device: Nexus 7 tab Android Version 4.1 SDK:3.1.2.v20130619101604 Appcelerator Studio: 3.1.1.201306131423 OS: OSX 10.8 acs:1.0.3 alloy:1.1.3 npm:1.2.14 titanium:3.1.1 titanium-code-processor:1.0.1

JSON Source