Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18411] iOS: A ListView's SearchBar doesn't filter when programmatically set

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-01-05T08:59:26.000+0000
Affected Version/sRelease 3.5.0
Fix Version/sRelease 5.4.0
ComponentsiOS
LabelsListView, SearchBar, qe-5.4.0
ReporterFokke Zandbergen
AssigneeSrikanth Sombhatla
Created2015-01-19T19:12:10.000+0000
Updated2016-06-15T19:00:56.000+0000

Description

Programmatically setting a SearchBar's value doesn't filter the ListView's rows where it is attached to, unless you focus/blur it. The value does show.

Expected behaviour

Setting the SearchBar value, either on creation or thereafter should filter the ListView (or TableView) it is attached to.

Steps to reproduce

1. Build an app with the following code 2. Confirm that both line 6 and 30 properly set the value but doesn't filter 3. Confirm that line 29 en 31 provide a workaround

Code to reproduce

var win = Ti.UI.createWindow({
  backgroundColor: 'white'
});

var searchView = Ti.UI.createSearchBar({
  value: 'Row 10'
});

var listView = Ti.UI.createListView({
  top: 20,
  searchView: searchView,
  sections: [Ti.UI.createListSection({
    items: (function() {
      var items = [];
      for (var i = 1; i < 30; i++) {
        items.push({
          properties: {
            title: 'Row ' + i,
            searchableText: 'Row ' + i
          }
        });
      }
      return items;
    })()
  })]
});

win.addEventListener('open', function() {
  // searchView.focus();
  searchView.value = 'Row 10';
  // searchView.blur();
});

win.add(listView);
win.open();

Comments

  1. Sebastian Klaus 2015-12-03

    I just get an project where I really could need this. The workaround does what it should. But it's ot very nice
  2. Srikanth Sombhatla 2016-01-04

    PR https://github.com/appcelerator/titanium_mobile/pull/7609
  3. Hans Knöchel 2016-01-05

    PR approved!
  4. Josh Longton 2016-06-15

    Verified as fixed. Tested on:
 iPhone 6s Plus (9.3.1) iOS Simulator (9.3) 
Mac OSX El Capitan 10.11.4 Studio: 4.7.0.201606150733 
Ti SDK: 5.4.0.v20160608165242 
Appc NPM: 4.2.7-2 Appc CLI: 5.4.0-15 
Xcode 7.3.1 Node v0.12.7 *
Closing Ticket.*

JSON Source