[TIMOB-6060] iOS: Blurring Textfield in Modal Window Doesn't Dismiss Keyboard
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-05-14T15:23:30.000+0000 |
Affected Version/s | Release 1.8.0 |
Fix Version/s | Release 4.1.0 |
Components | iOS |
Labels | n/a |
Reporter | Dawson Toth |
Assignee | Chee Kiat Ng |
Created | 2011-11-08T09:04:10.000+0000 |
Updated | 2015-06-10T00:13:32.000+0000 |
Description
When using the MODAL_PRESENTATION_FORMSHEET modal style, iOS by default does not dismiss the keyboard even when text fields are blurred. iOS 4.3 and later allows us to override this, but this property is not currently exposed.
This will be an iOS-only property on the Ti.UI.Window class, and will not apply to Android.
In the mean time, MODAL_PRESENTATION_PAGESHEET is perfectly sufficient.
(Not a bug, but leaving old comments)
Problem
When blurring a text field in a modal window, the keyboard doesn't go away.Reproduction
Drop the following in an app.js, and click in the text field. It automatically blurs itself after gaining focus. If you change "modal: true" to "modal: false", the keyboard will properly hide itself.
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var textField = Ti.UI.createTextField({
value: '1. Touch Me',
height: 34, top: 10, left: 10, right: 10,
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
textField.addEventListener('focus', function () {
Ti.API.info('blurring');
textField.blur();
Ti.API.info('blurred');
});
win.add(textField);
win.open({
modal: true,
modalStyle: Ti.UI.iPhone.MODAL_PRESENTATION_FORMSHEET
});
This is actually not a bug, but due to Apple's design. Namely, in http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html : "The default implementation of this method returns YES when the modal presentation style of the view controller is set to UIModalPresentationFormSheet and returns NO for other presentation styles. Thus, the system normally does not allow the keyboard to be dismissed for modal forms." The method that we can override for this is available in iOS 4.3 and later, so any feature request to change this behavior would not change 3.x to 4.2. Updating bug to be feature request instead.
Talked with Dawson, he's going to ping customer and see if it's a must-have for 1.8 or if this can fall into TBS, especially since some versions of 4.0 won't support this.
@Tim - We are probably not going to get to it in the next release but we can schedule it for later.
It's now 2014 and this feature hasn't been implemented. I got into a mini-hair pulling craze for a while when I couldn't figure out why something as simple as blurring wasn't working for me. I then started to doubt my coding skills. However, at last! I found this gem here explaining the details. I don't want to use a full screen modal and the FORMSHEET looks more sleek having the content in the background still showing. This is important for my apps user interaction because the keyboard needs to hide after doing something else in the modal box to reveal the Save button. I've seen at least 3 people now being confused on what to do because the keyboard blocks the Save. I can move the Save button but it won't look as good. I was wondering what work around is there to this other than using PAGESHHEET?
http://stackoverflow.com/questions/3372333/ipad-keyboard-will-not-dismiss-if-modal-view-controller-presentation-style-is-ui
Doing this on objective-c will make this work. Where do I apply this for titanium?
my question is: why is this ticket still open? I stumbled open this bug after 3 years it was reported. And it still happens with TiSDK 3.2.1 .
[~a.marcone] it appears to have just slipped by. Thank you for reminding us. Seeing when we can schedule it in.
awesome! thank you for taking care of it.
This is causing awkward usability problems for us too. Any ETA on when it will be fixed?
ok, 3 months passed by, and still not scheduled. Anyone? Please?
ok, I will be honest: being scheduled for the 3.4.0 means that we'll be stuck with this bug for the next 7 months. Kinda frustrating. Thank you anyways, I'm sure you're doing your job like I'm doing mine.. but it's been reported 3 years ago..
+1
as [~blainhamon] has mentioned, According to apple reference here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/disablesAutomaticKeyboardDismissal "The default implementation of this method returns YES when the modal presentation style of the view controller is set to UIModalPresentationFormSheet and returns NO for other presentation styles." Since we support the blur method, it should be ok to default the mentioned method to NO for all cases since it only affects UIModalPresentationFormSheet. PR here: https://github.com/appcelerator/titanium_mobile/pull/6846
Verified the fix. The textfield is dismissed as expected. Closing. Environment: Appc Studio : 4.1.0.201505071004 Ti SDK : 4.1.0.v20150605164428 Ti CLI : 4.0.1 Alloy : 1.6.0 MAC Yosemite : 10.10.3 Appc npm : 4.0.0 Appc CLI : 4.0.2-rc2 Node: v0.10.37 IOS Simulator: Iphone 5 IOS 8.3