Skip to content

Commit a796786

Browse files
committed
fix(all): boolean inputs
fixes #9391
1 parent cac7164 commit a796786

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

src/components/range/range.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ export class RangeKnob implements OnInit {
4141
_ratio: number;
4242
_val: number;
4343
_x: string;
44+
_upper: boolean = false;
4445
pressed: boolean;
4546

46-
@Input() upper: boolean;
47+
@Input()
48+
get upper(): boolean {
49+
return this._upper;
50+
}
51+
set upper(val: boolean) {
52+
this._upper = isTrueProperty(val);
53+
}
4754

4855
constructor( @Inject(forwardRef(() => Range)) public range: Range) { }
4956

@@ -81,7 +88,7 @@ export class RangeKnob implements OnInit {
8188
// we already have a value
8289
if (this.range.dualKnobs) {
8390
// we have a value and there are two knobs
84-
if (this.upper) {
91+
if (this._upper) {
8592
// this is the upper knob
8693
this.value = this.range.value.upper;
8794

src/components/searchbar/searchbar.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ import { TimeoutDebouncer } from '../../util/debouncer';
4444
'</div>' +
4545
'<button ion-button #cancelButton mode="ios" [tabindex]="_isActive ? 1 : -1" clear (click)="cancelSearchbar($event)" (mousedown)="cancelSearchbar($event)" class="searchbar-ios-cancel" type="button">{{cancelButtonText}}</button>',
4646
host: {
47-
'[class.searchbar-animated]': 'animated',
47+
'[class.searchbar-animated]': '_animated',
4848
'[class.searchbar-has-value]': '_value',
4949
'[class.searchbar-active]': '_isActive',
50-
'[class.searchbar-show-cancel]': 'showCancelButton',
50+
'[class.searchbar-show-cancel]': '_showCancelButton',
5151
'[class.searchbar-left-aligned]': '_shouldAlignLeft'
5252
},
5353
encapsulation: ViewEncapsulation.None
@@ -62,6 +62,8 @@ export class Searchbar extends Ion {
6262
_autocorrect: string = 'off';
6363
_isActive: boolean = false;
6464
_debouncer: TimeoutDebouncer = new TimeoutDebouncer(250);
65+
_showCancelButton: boolean = false;
66+
_animated: boolean = false;
6567

6668
/**
6769
* @input {string} The predefined color to use. For example: `"primary"`, `"secondary"`, `"danger"`.
@@ -87,7 +89,13 @@ export class Searchbar extends Ion {
8789
/**
8890
* @input {boolean} Whether to show the cancel button or not. Default: `"false"`.
8991
*/
90-
@Input() showCancelButton: any = false;
92+
@Input()
93+
get showCancelButton(): boolean {
94+
return this._showCancelButton;
95+
}
96+
set showCancelButton(val: boolean) {
97+
this._showCancelButton = isTrueProperty(val);
98+
}
9199

92100
/**
93101
* @input {number} How long, in milliseconds, to wait to trigger the `ionInput` event after each keystroke. Default `250`.
@@ -135,9 +143,15 @@ export class Searchbar extends Ion {
135143
@Input() type: string = 'search';
136144

137145
/**
138-
* @input {string|boolean} Configures if the searchbar is animated or no. By default, animation is disabled.
146+
* @input {boolean} Configures if the searchbar is animated or no. By default, animation is `false`.
139147
*/
140-
@Input() animated: string | boolean = false;
148+
@Input()
149+
get animated(): boolean {
150+
return this._animated;
151+
}
152+
set animated(val: boolean) {
153+
this._animated = isTrueProperty(val);
154+
}
141155

142156
/**
143157
* @output {event} When the Searchbar input has changed including cleared.
@@ -232,7 +246,7 @@ export class Searchbar extends Ion {
232246
* based on the input value and if it is focused. (ios only)
233247
*/
234248
positionElements() {
235-
let isAnimated = isTrueProperty(this.animated);
249+
let isAnimated = this._animated;
236250
let prevAlignLeft = this._shouldAlignLeft;
237251
let shouldAlignLeft = (!isAnimated || (this._value && this._value.toString().trim() !== '') || this._sbHasFocus === true);
238252
this._shouldAlignLeft = shouldAlignLeft;

src/components/searchbar/test/basic/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h5 padding-left> Search - Custom Placeholder </h5>
1717
</p>
1818

1919
<h5 padding-left> Search - No Cancel Button </h5>
20-
<ion-searchbar autocorrect="off" autocomplete="off" spellcheck="true" type="text" [(ngModel)]="defaultCancel" (ionInput)="triggerInput($event)" (ionCancel)="onCancelSearchbar($event)" (ionClear)="onClearSearchbar($event)"></ion-searchbar>
20+
<ion-searchbar autocorrect="off" autocomplete="off" spellcheck="true" type="text" [(ngModel)]="defaultCancel" (ionInput)="triggerInput($event)" (ionCancel)="onCancelSearchbar($event)" (ionClear)="onClearSearchbar($event)" showCancelButton="false"></ion-searchbar>
2121

2222
<p padding-left>
2323
defaultCancel: <b>{{ defaultCancel }}</b>

src/components/spinner/spinner.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ChangeDetectionStrategy, Component, ElementRef, Input, Renderer, ViewEn
33
import { Config } from '../../config/config';
44
import { Ion } from '../ion';
55
import { CSS } from '../../util/dom';
6+
import { isTrueProperty } from '../../util/util';
7+
68
/**
79
* @name Spinner
810
* @description
@@ -106,7 +108,7 @@ import { CSS } from '../../util/dom';
106108
'<line [attr.y1]="i.y1" [attr.y2]="i.y2" transform="translate(32,32)"></line>' +
107109
'</svg>',
108110
host: {
109-
'[class.spinner-paused]': 'paused'
111+
'[class.spinner-paused]': '_paused'
110112
},
111113
changeDetection: ChangeDetectionStrategy.OnPush,
112114
encapsulation: ViewEncapsulation.None,
@@ -118,6 +120,7 @@ export class Spinner extends Ion {
118120
_dur: number = null;
119121
_init: boolean;
120122
_applied: string;
123+
_paused: boolean = false;
121124

122125
/**
123126
* @input {string} The predefined color to use. For example: `"primary"`, `"secondary"`, `"danger"`.
@@ -145,7 +148,6 @@ export class Spinner extends Ion {
145148
get name(): string {
146149
return this._name;
147150
}
148-
149151
set name(val: string) {
150152
this._name = val;
151153
this.load();
@@ -158,16 +160,21 @@ export class Spinner extends Ion {
158160
get duration(): number {
159161
return this._dur;
160162
}
161-
162163
set duration(val: number) {
163164
this._dur = val;
164165
this.load();
165166
}
166167

167168
/**
168-
* @input {string} If the animation is paused or not. Defaults to `false`.
169+
* @input {boolean} If the animation is paused or not. Defaults to `false`.
169170
*/
170-
@Input() paused: boolean = false;
171+
@Input()
172+
get paused(): boolean {
173+
return this._paused;
174+
}
175+
set paused(val: boolean) {
176+
this._paused = isTrueProperty(val);
177+
}
171178

172179
constructor(config: Config, elementRef: ElementRef, renderer: Renderer) {
173180
super(config, elementRef, renderer, 'spinner');

0 commit comments

Comments
 (0)