diff --git a/apps/app/ui-tests-app/search-bar/issue-5655.xml b/apps/app/ui-tests-app/search-bar/issue-5655.xml
new file mode 100644
index 000000000..fab139506
--- /dev/null
+++ b/apps/app/ui-tests-app/search-bar/issue-5655.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/app/ui-tests-app/search-bar/main-page.ts b/apps/app/ui-tests-app/search-bar/main-page.ts
index cf77e4cf3..63577e10d 100644
--- a/apps/app/ui-tests-app/search-bar/main-page.ts
+++ b/apps/app/ui-tests-app/search-bar/main-page.ts
@@ -11,8 +11,10 @@ export function pageLoaded(args: EventData) {
export function loadExamples() {
const examples = new Map();
- examples.set("issue-4147", "search-bar/issue-4147");
- examples.set("search-bar", "search-bar/search-bar");
- examples.set("issue-5039","search-bar/issue-5039");
+ examples.set("issue-4147", "search-bar/issue-4147");
+ examples.set("search-bar", "search-bar/search-bar");
+ examples.set("issue-5039", "search-bar/issue-5039");
+ examples.set("issue-5655", "search-bar/issue-5655");
+
return examples;
}
diff --git a/tns-core-modules/ui/search-bar/search-bar.ios.ts b/tns-core-modules/ui/search-bar/search-bar.ios.ts
index eb7b00cd5..ea7cf4882 100644
--- a/tns-core-modules/ui/search-bar/search-bar.ios.ts
+++ b/tns-core-modules/ui/search-bar/search-bar.ios.ts
@@ -3,9 +3,12 @@ import {
SearchBarBase, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, fontInternalProperty,
textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty
} from "./search-bar-common";
+import { ios as iosUtils } from "../../utils/utils";
export * from "./search-bar-common";
+const majorVersion = iosUtils.MajorVersion;
+
class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
public static ObjCProtocols = [UISearchBarDelegate];
@@ -52,6 +55,18 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
}
}
+class UISearchBarImpl extends UISearchBar {
+ sizeThatFits(size: CGSize): CGSize {
+ // iOS11 SDK does not support passing sizeThatFits(...) non-finite width value;
+ // iOS layout system will take care to size the element properly when passed 0
+ if (majorVersion >= 11 && size.width === Number.POSITIVE_INFINITY) {
+ size.width = 0;
+ }
+
+ return super.sizeThatFits(size);
+ }
+}
+
export class SearchBar extends SearchBarBase {
private _ios: UISearchBar;
private _delegate;
@@ -61,7 +76,7 @@ export class SearchBar extends SearchBarBase {
constructor() {
super();
- this.nativeViewProtected = this._ios = UISearchBar.new();
+ this.nativeViewProtected = this._ios = UISearchBarImpl.new();
this._delegate = UISearchBarDelegateImpl.initWithOwner(new WeakRef(this));
}