Problem Description
Once you set the html property in a label, the click event is lost.
Test Case
1. Create a new mobile project Classic titanium
2. Paste this code into app.js:
var win = Ti.UI.createWindow({
backgroundColor: "#fff"
});
var lbl = Ti.UI.createLabel({
backgroundColor: "red",
html: "Click <b>here</b> <a href=\"http://www.w3schools.com\">Visit W3Schools.com!</a>"
});
lbl.addEventListener("click", function(){
alert("clicked");
});
win.add(lbl);
win.open();
3. Run it in a 4.0.x device.
4. Click the label
Expected results
After clicking the label, an alert should appear.
Actual results
alert is not shown.
Problem can be reproduced on Titanium SDK 3.4.0.GA Android 2.3.6 SAMSUNG-SGH-I777
Seems this issue exists with 4.0 too. Reproduced on the following devices. 1. Galaxy S2 GT-i1900 - Android 4.0.3 2. Motorola MB526 - Android 2.3.4 But working fine with following devices, 1. Nexus 4 - Android 4.4.4 2. Galaxy S4 GT-I9500 - Android 4.4.2
PR: https://github.com/appcelerator/titanium_mobile/pull/6460
I would be careful when testing, and make sure that anchor tags in the html still click properly, too.
Added an anchor tag to the test case. For FR, please run the test case on pre-JB device and click the label to see the alert. If you click on the hyperlink inside the label, it will open the browser and go to that webpage.
Verified the fix. Click event works even after setting the labels html property. Closing Environment: Appc Studio : 3.4.1.201410281743 Ti SDK : 3.5.0.v20150106150919, 3.6.0.v20150106160923 CLI : 3.4.1 Alloy : 1.5.1 GA Code Processor : 1.1.1 MAC Yosemite : 10.10 Samsung Galaxy S3 - android 4.0.4
~lchoudhary, were you able to test this on android 2.3 (API level 10) and above devices. I tested with 3.5.0.GA and it fails.
Below is the matrix for the results on different android versions for this issue: ||SDK 3.6.0.v20150127082526|| Result|| |2.3.7| Alert is seen |4.0.4| Alert is seen |4.1.1| Alert is seen |4.3| Alert is seen |4.2.2| Alert is seen |4.4.4| No alert seen |5.0.1| No alert seen ||SDK 3.5.0.GA|| Result|| |2.3.7| No alert seen |4.0.4| No alert seen |4.1.1| Alert is seen |4.3| Alert is seen |4.2.2| Alert is seen |4.4.4| No alert seen |5.0.1| No alert seen Please note the fix version is "Release 3.6.0". Reopening the ticket as this issue is seen in android 4.4.4 & 5.0.1 when built with SDK 3.6.0.v20150127082526. Environment: Appc Studio : 3.4.1.201410281743 Ti SDK : 3.5.0.GA, 3.6.0.v20150127082526 CLI : 3.4.1 Alloy : 1.5.1 GA Code Processor : 1.1.1 MAC Yosemite : 10.10
Trying to reproduce this with 4.4.4 and 5.0.0 Android on master branch. So far, unable to reproduce.
Tried this with:- Master Branch 3.5.1.GA 3.5.0.GA 3.4.1.GA With the following Android OS: 4.4.2 Samsung Galaxy S 5 (SM-G900F) 4.4.4 Nexus 4 5.0 Nexus 9 Unable to reproduce. Able to click the label and get an alert. Also able to click the website link which opens the web browser.
[~lchoudhary] Are you still able to reproduce this?
[~msamah]I tried to reproduce the issue on the devices below with SDK 4.0.0.v20150323131014 & I am not able to see the issue: 1. Galaxy Nexus 4.2.2 - Alert is seen. 2. Samsung Galaxy S2 2.3.6 - Alert is seen. 3. Nexus 5 5.1- Alert is seen. Environment: Appc Studio : 4.0.0.201503232213 Ti SDK : 4.0.0.v20150323131014 CLI : 4.0.0-alpha Alloy : 1.6.0-alpha MAC Yosemite : 10.10.2
[~lchoudhary] I'll resolve this ticket as issue is not reproducible.
Does it mean we fix it in Ti.SDK 4.0
This problem shouldn't be seen in Ti.SDK 4.0.
Got it. Thanks
[~sdavenport] This was incorrectly assigned a fix version. That said, it may actually be fixed--we just can't reproduce it any more.
Closing ticket as I am unable to reproduce this issue with the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80