[TIMOB-10584] Android: WebView click event is not being fired
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-06-21T07:16:32.000+0000 |
Affected Version/s | Release 2.1.1 |
Fix Version/s | Release 3.0.0, Sprint 2012-18 API |
Components | Android |
Labels | api, module_webview, parity, qe-testadded, regression |
Reporter | Nikhil Sharma |
Assignee | Karl Rowley |
Created | 2012-08-23T18:03:42.000+0000 |
Updated | 2019-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();
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:
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.
Pull request https://github.com/appcelerator/titanium_mobile/pull/2853
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
Reopening just to update label.
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