Skip to content

Commit

Permalink
[TIMOB-25414](7_0_X) : iOS Search bar in absolute-positioned ListView…
Browse files Browse the repository at this point in the history
… extends when focused (#9657)

* [TIMOB-25414] : iOS Search bar in absolute-positioned ListView extends when focused

* [TIMOB-25414] :  Unit test  added
  • Loading branch information
vijaysingh-axway authored and ewieberappc committed Dec 15, 2017
1 parent ee87c7b commit 9423ebb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,7 @@ - (void)didDismissSearchController:(UISearchController *)searchController
[_tableView reloadData];

RELEASE_TO_NIL(searchControllerPresenter);
[searchViewProxy ensureSearchBarHierarchy];
}

- (void)presentSearchController:(UISearchController *)controller
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUISearchBarProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ - (void)ensureSearchBarHierarchy
UISearchBar *searchBar = [self searchBar];
if ([searchBar superview] != view) {
[view addSubview:searchBar];
[searchBar setFrame:[view bounds]];
}
[searchBar setFrame:[view bounds]];
}
}

Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,7 @@ - (void)didDismissSearchController:(UISearchController *)searchController
[self setSearchString:nil];
RELEASE_TO_NIL(searchResultIndexes);
RELEASE_TO_NIL(searchControllerPresenter);
[searchField ensureSearchBarHierarchy];
}

- (void)presentSearchController:(UISearchController *)controller
Expand Down
51 changes: 51 additions & 0 deletions tests/Resources/ti.ui.searchbar.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* global Ti */
/* eslint no-unused-expressions: "off" */
'use strict';
var should = require('./utilities/assertions');

describe('Titanium.UI.SearchBar', function () {
it.ios('Should work with absolute-positioned search-bars (ListView)', function (finish) {
var data = [ { properties: { title : 'Bashful', hasDetail: true } }];

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

win.addEventListener('open', function () {
should(listView.top).eql(50);
should(listView.bottom).eql(50);
should(listView.left).eql(40);
should(listView.right).eql(40);

should(searchBar.getWidth()).eql(150);

setTimeout(function () {
win.close();
finish();
}, 1000);
});

var searchBar = Ti.UI.createSearchBar( {
width : 150
});

var listView = Ti.UI.createListView( {
backgroundColor : '#999',
searchView : searchBar,
sections : [Ti.UI.createListSection({items: data})],
top : 50,
bottom : 50,
left : 40,
right : 40
});
win.add(listView);
win.open();
});
});

0 comments on commit 9423ebb

Please sign in to comment.