Merge pull request #1539 from speigg/patch-1

Fix clearEvent after programmatically setting text
This commit is contained in:
Vladimir Enchev
2016-02-15 10:59:49 +02:00

View File

@ -70,7 +70,6 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
public static ObjCProtocols = [UISearchBarDelegate]; public static ObjCProtocols = [UISearchBarDelegate];
private _owner: WeakRef<SearchBar>; private _owner: WeakRef<SearchBar>;
private _searchText: string;
public static initWithOwner(owner: WeakRef<SearchBar>): UISearchBarDelegateImpl { public static initWithOwner(owner: WeakRef<SearchBar>): UISearchBarDelegateImpl {
let delegate = <UISearchBarDelegateImpl>UISearchBarDelegateImpl.new(); let delegate = <UISearchBarDelegateImpl>UISearchBarDelegateImpl.new();
@ -87,11 +86,9 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
owner._onPropertyChangedFromNative(common.SearchBar.textProperty, searchText); owner._onPropertyChangedFromNative(common.SearchBar.textProperty, searchText);
// This code is needed since sometimes searchBarCancelButtonClicked is not called! // This code is needed since sometimes searchBarCancelButtonClicked is not called!
if (searchText === "" && this._searchText !== searchText) { if (searchText === "") {
owner._emit(common.SearchBar.clearEvent); owner._emit(common.SearchBar.clearEvent);
} }
this._searchText = searchText;
} }
public searchBarCancelButtonClicked(searchBar: UISearchBar) { public searchBarCancelButtonClicked(searchBar: UISearchBar) {