Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3089] iPhone: SearchBar UI Doesn't get fully rendered when focus() is added before the window is opened

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-08-30T16:51:58.000+0000
Affected Version/sRelease 1.6.0 M10
Fix Version/sn/a
ComponentsiOS
Labelsdefect, ios, reported-1.6.0, rplist, tbs-1.9.0
ReporterRick Blalock
AssigneeNeeraj Gupta
Created2011-04-15T03:36:36.000+0000
Updated2017-03-23T21:12:34.000+0000

Description

This could be a defect or just an issue of what is best practice.

If you set a focus() on the SearchBar before the window is opened it doesn't get fully rendered (see customer's example) or will draw it on the canvas realtime (See video link below). The workaround is simple: place the focus() after the window is opened or delay the focus event a few ms.

Sample Code: http://pastie.org/1545123">http://pastie.org/1545123
Video: http://www.screencast.com/users/XiDScreencasts/folders/Jing/media/4a51feee-e70e-4cd0-bfcd-b751661d3943"> http://www.screencast.com/users/XiDScreencasts/folders/Jing/media/4...
HD Ticket (Customer's sample code there): http://developer.appcelerator.com/helpdesk/view/66091#c340591">http://developer.appcelerator.com/helpdesk/view/66091#c340591

Comments

  1. James David Low 2011-08-05

    I'm having a similar problem when the table view is added before the window is opened. Code showing the bug: var tabGroup = Titanium.UI.createTabGroup(); var win1 = Titanium.UI.createWindow({title:'Tab 1',backgroundColor:'#fff'}); var tab1 = Titanium.UI.createTab({title:'Tab 1',window:win1}); function createTableView() { var search = Titanium.UI.createSearchBar(); var tableview = Titanium.UI.createTableView({ data:[{title:'New Table View'}], search:search, filterAttribute:'title' }); tableview.addEventListener('click',function(e) {createTableView();}); win1.add(tableview); } createTableView(); tabGroup.addTab(tab1); tabGroup.open();
  2. Federico Casali 2012-05-16

    Jira bug review - reproducing same video behavior with 2.0 GA and 2.1 CI SDK
  3. Junaid Younus 2012-08-30

    Tested on the iOS Simulator using TiSDK 2.2.0v20120830102513, unable to reproduce the issue. Everything seems to be fine and fully loaded. Ticket marked as resolved.
       var win = Titanium.UI.createWindow({backgroundColor: 'white'});
       
       
       var searchBar = Ti.UI.createSearchBar({
           barColor: '#00f',
           showCancel: false,
           hintText: 'Search for Something'
       });
       var searchHasFocus = false;
       
       var tableView = Ti.UI.createTableView({
           backgroundColor: 'white',
           search: searchBar
       });
       
       searchBar.addEventListener('focus', function(e) {
           searchHasFocus = true;
           e.source.showCancel = true;
       });
       
       searchBar.addEventListener('blur', function(e) {
           searchHasFocus = false;
           e.source.showCancel = false;
       });
       
       searchBar.addEventListener('return', function(e) {
           if (searchHasFocus) searchBar.blur();
       });
       
       searchBar.addEventListener('cancel', function(e) {
           searchBar.blur();
       });
       
       tableView.addEventListener('touchstart', function(e) {
           if (searchHasFocus) searchBar.blur();
       });
       
       tableView.addEventListener('scroll', function(e) {
           if (searchHasFocus) searchBar.blur();
       });
       
       win.add(tableView);
       
       searchBar.focus();
       
       win.open();
       
  4. Lee Morris 2017-03-23

    Can verify this ticket as "Cannot Reproduce". Tested with the following environment; iPhone 7 and Simulator (10.2) 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

JSON Source