Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17343] iOS: onBlur event on Textfield fired twice when click return button on keyboard

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-03-08T03:34:57.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
LabelsTextfield, ios, onBlur
ReporterDavid He
AssigneeAngel Petkov
Created2014-07-16T12:21:17.000+0000
Updated2017-03-31T22:44:42.000+0000

Description

onBlur event on Textfield fired twice when click return button on key borad. Here is the latest test case for this problem.
var win = Ti.UI.createWindow({
    backgroundColor : 'white'
});
 
var plainTemplate = {
    childTemplates : [{
        type : 'Ti.UI.TextField',
        bindId : 'button',
        properties : {
            width : '80dp',
            height : '30dp',
            right : '10dp',
            value : "122222",
            borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED
        },
        events : {
            blur : function() {
                alert("???");
            }
        }
    }]
};
 
var listView = Ti.UI.createListView({
    templates : {
        'plain' : plainTemplate
    },
    defaultItemTemplate : 'plain'
});
 
var data = [];
for (var i = 0; i < 10; i++) {
    data.push({
        rowtitle : {
            text : 'Row ' + (i + 1)
        },
        properties : {
            itemId : 'row' + (i + 1),
            accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_NONE
        }
    });
}
 
var section = Ti.UI.createListSection({
    items : data
});
listView.sections = [section];
win.add(listView);
win.open();

Comments

  1. Shuo Liang 2014-07-17

    Can't reproduce.
  2. David He 2014-07-17

    Just extracted what I think possible to recreate the bug from my project and pasted the code here - have not tested the sample code here. I will modify the code and update it. Thanks
  3. David He 2014-07-17

       var win = Ti.UI.createWindow({
       	backgroundColor : 'white'
       });
       
       var plainTemplate = {
       	childTemplates : [{
       		type : 'Ti.UI.TextField',
       		bindId : 'button',
       		properties : {
       			width : '80dp',
       			height : '30dp',
       			right : '10dp',
       			value : "122222",
       			borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED
       		},
       		events : {
       			blur : function() {
       				alert("???");
       			}
       		}
       	}]
       };
       
       var listView = Ti.UI.createListView({
       	templates : {
       		'plain' : plainTemplate
       	},
       	defaultItemTemplate : 'plain'
       });
       
       var data = [];
       for (var i = 0; i < 10; i++) {
       	data.push({
       		rowtitle : {
       			text : 'Row ' + (i + 1)
       		},
       		properties : {
       			itemId : 'row' + (i + 1),
       			accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_NONE
       		}
       	});
       }
       
       var section = Ti.UI.createListSection({
       	items : data
       });
       listView.sections = [section];
       win.add(listView);
       win.open();
       
       
       
       
  4. David He 2014-07-17

    The above code snippet can definitely generate the issue - tested
  5. Shuo Liang 2014-07-17

    Hi, What kind of device did you use when you find the problem, as I can't reproduce it with iOS 7.1 simulator. Regards, Shuo
  6. David He 2014-07-17

    iOS 7.1. Are you using the updated code?
  7. David He 2014-07-17

    Appears to be a general problem not a ALLOY specific one. Just use the updated code and you can readily reproduce it. Thanks
  8. Shuo Liang 2014-07-17

    I WAS using the updated code. still can't reproduce your problem. Even tried with different simulator, different SDK and also iphone 4 device, none of them can reproduce your problem.
  9. Shuo Liang 2014-07-17

    Would you please try to clean the project and restart the studio and simulator. See if the problem still appears.
  10. David He 2014-07-17

    What is your testing environment ? Ti SDK?
  11. Shuo Liang 2014-07-17

    ye,I tried SDK 3.2.2, 3.2.3 and 3.3.0. all same.
  12. David He 2014-07-17

    Bizarre!~ Let me clean the project and give it another go. Will update you shortly
  13. David He 2014-07-17

    I tried clean the project still have this issue. Issue is firstly focus on anyone of these textfields and hit search/done button on textfield will trigger blur event twice..... You will see ??? two times....
  14. David He 2014-07-17

    I take a screen recording but unable to attach it to this ticket since it is being closed....
  15. Shuo Liang 2014-07-17

    Oh I see you problem. I thought you just want the event lost the focus. Now I can reproduce the problem. I will forward this ticket to our engineer team. Thank you for your case.
  16. David He 2014-07-17

    Awesome, hopefully it could get sorted out by the next sub-version release of Ti.SDK. Thanks BTW, whereabouts are you? US? Then would`t be too late for you???
  17. David He 2014-07-17

    As a side note, return event will fire only once as opposed to blur..... Interesting.....
  18. John Jardin 2015-09-23

    Hi there. I see this is listed as a bug (with a low priority), but I must say this is quite a serious issue. It only started when my app (using iOS7 SDK) was being used on iOS 8 Operating System. I then re-compiled the app to use iOS 8.2 SDK, but the issue remains. I use this scenario for field validation. What happens now is if the user enters something in the field where validation fails, the Return event triggers once, whilst the Blur event triggers twice.
  19. Angel Petkov 2015-12-16

    Tested the Issue with the newest SDK with iOS 8.4 and higher. The issue doesn't seem to be reproducible, using the test code provided.Have you tried running the app on the newest [SDK](http://builds.appcelerator.com.s3.amazonaws.com/index.html#5_1_X) ?
  20. Lee Morris 2017-03-31

    Closing ticket as "Cannot Reproduce", if you encounter any further problems please file a new ticket.

JSON Source