Skip to content

Commit 7a6ba2d

Browse files
brandyscarneyadamdbradley
authored andcommitted
fix(input): show clear-input on inputs with ngModel/formControlName
fixes #9077
1 parent 2ee05b8 commit 7a6ba2d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/components/input/input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export class TextInput extends Ion implements IonicFormInput {
301301

302302
nativeInput.valueChange.subscribe((inputValue: any) => {
303303
this.onChange(inputValue);
304+
this.checkHasValue(inputValue);
304305
});
305306

306307
nativeInput.keydown.subscribe((inputValue: any) => {

src/components/input/test/clear-input/app.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import { Component, NgModule } from '@angular/core';
2+
import { FormBuilder, Validators } from '@angular/forms';
3+
24
import { IonicApp, IonicModule } from '../../../../../ionic-angular';
35

46

57
@Component({
68
templateUrl: 'main.html'
79
})
810
export class E2EPage {
11+
userForm: any;
912
myValue = 'really long value that overflows to show padding';
1013

14+
constructor(fb: FormBuilder) {
15+
this.userForm = fb.group({
16+
username: [{value: '', disabled: false}, Validators.required],
17+
password: [{value: '', disabled: false}, Validators.required],
18+
});
19+
}
20+
1121
clicked() {
1222
console.log('clicked button');
1323
}

src/components/input/test/clear-input/main.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<ion-input class="e2eClearInput" [(ngModel)]="myValue"></ion-input>
1717
</ion-item>
1818

19+
<ion-item>
20+
<ion-label>Input Clear No ngModel:</ion-label>
21+
<ion-input clearInput></ion-input>
22+
</ion-item>
23+
1924
<ion-item>
2025
<ion-label>Input Clear:</ion-label>
2126
<ion-input class="e2eClearInput" [(ngModel)]="myValue" clearInput></ion-input>
@@ -33,4 +38,20 @@
3338
</ion-item>
3439
</ion-list>
3540

41+
<form [formGroup]="userForm">
42+
<ion-list>
43+
<ion-list-header>
44+
Form w/ clearInput
45+
</ion-list-header>
46+
<ion-item>
47+
<ion-label floating>Username</ion-label>
48+
<ion-input formControlName="username" clearInput></ion-input>
49+
</ion-item>
50+
<ion-item>
51+
<ion-label floating>Password</ion-label>
52+
<ion-input type="password" formControlName="password" clearInput></ion-input>
53+
</ion-item>
54+
</ion-list>
55+
</form>
56+
3657
</ion-content>

0 commit comments

Comments
 (0)