Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25414](7_0_X) : iOS Search bar in absolute-positioned ListView extends when focused #9657

Merged
merged 7 commits into from
Dec 15, 2017
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();
});
});