Skip to content

Commit 71cd297

Browse files
committed
fix(input): remove old clearInput code and clean up UI, added onChange calls
references #6514
1 parent 619f119 commit 71cd297

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

ionic/components/input/input-base.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,6 @@ export class InputBase {
401401
}
402402
}
403403

404-
/**
405-
* @private
406-
*/
407-
clearTextInput() {
408-
console.debug('Should clear input');
409-
this._value = '';
410-
}
411-
412404
/**
413405
* @private
414406
*/

ionic/components/input/input.ios.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ ion-input[clearInput] {
8080
bottom: 0;
8181

8282
width: $text-input-ios-input-clear-icon-width;
83+
height: 34px;
8384

8485
background-size: $text-input-ios-input-clear-icon-size;
8586
}

ionic/components/input/input.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ion-input[clearInput] {
112112
@include svg-background-image($text-input-md-input-clear-icon-svg);
113113

114114
right: ($item-md-padding-right / 2);
115-
bottom: 2px;
115+
bottom: 4px;
116116

117117
width: $text-input-md-input-clear-icon-width;
118118

ionic/components/input/input.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ input.text-input:-webkit-autofill {
127127

128128
.text-input-clear-icon {
129129
position: absolute;
130+
display: none;
130131

131132
margin: 0;
132133
padding: 0;
@@ -135,6 +136,10 @@ input.text-input:-webkit-autofill {
135136
background-position: center;
136137
}
137138

139+
.input-has-value .text-input-clear-icon {
140+
display: block;
141+
}
142+
138143

139144
// Cloned Input
140145
// --------------------------------------------------

ionic/components/input/input.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import {Platform} from '../../platform/platform';
6666
template:
6767
'<input [type]="type" [(ngModel)]="_value" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" [placeholder]="placeholder" class="text-input">' +
6868
'<input [type]="type" aria-hidden="true" next-input *ngIf="_useAssist">' +
69-
'<button clear *ngIf="clearInput && value" type="button" class="text-input-clear-icon" (click)="clearTextInput()" (mousedown)="clearTextInput()"></button>' +
69+
'<button clear [hidden]="!clearInput" type="button" class="text-input-clear-icon" (click)="clearTextInput()" (mousedown)="clearTextInput()"></button>' +
7070
'<div (touchstart)="pointerStart($event)" (touchend)="pointerEnd($event)" (mousedown)="pointerStart($event)" (mouseup)="pointerEnd($event)" class="input-cover" tappable *ngIf="_useAssist"></div>',
7171
directives: [
7272
NextInput,
@@ -107,7 +107,10 @@ export class TextInput extends InputBase {
107107
* @private
108108
*/
109109
clearTextInput() {
110+
console.debug("Should clear input");
110111
this._value = '';
112+
this.onChange(this._value);
113+
this.writeValue(this._value);
111114
}
112115
}
113116

ionic/components/input/input.wp.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ion-input[clearInput] {
108108
@include svg-background-image($text-input-wp-input-clear-icon-svg);
109109

110110
right: ($item-wp-padding-right / 2);
111-
bottom: 2px;
111+
bottom: 7px;
112112

113113
width: $text-input-wp-input-clear-icon-width;
114114

ionic/components/input/test/form-inputs/main.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
<form [ngFormModel]="loginForm" #mf="ngForm" novalidate>
88

99
<ion-list>
10-
<ion-item clearInput>
10+
<ion-item>
1111
<ion-label floating>Email</ion-label>
12-
<ion-input [(ngModel)]="login.email" ngControl="email" type="email" required></ion-input>
12+
<ion-input clearInput [(ngModel)]="login.email" ngControl="email" type="email" required></ion-input>
1313
</ion-item>
1414

15-
<ion-item clearInput>
15+
<ion-item>
1616
<ion-label floating>Username</ion-label>
17-
<ion-input [(ngModel)]="login.username" ngControl="username"></ion-input>
17+
<ion-input clearInput [(ngModel)]="login.username" ngControl="username"></ion-input>
1818
</ion-item>
1919

20-
<ion-item clearInput>
20+
<ion-item>
2121
<ion-label>Password</ion-label>
22-
<ion-input [(ngModel)]="login.password" ngControl="password" type="password" required></ion-input>
22+
<ion-input clearInput [(ngModel)]="login.password" ngControl="password" type="password" required></ion-input>
2323
</ion-item>
2424

25-
<ion-item clearInput>
25+
<ion-item>
2626
<ion-label>Comments</ion-label>
27-
<ion-textarea [(ngModel)]="login.comments" ngControl="comments" required>Comment value</ion-textarea>
27+
<ion-textarea clearInput [(ngModel)]="login.comments" ngControl="comments" required>Comment value</ion-textarea>
2828
</ion-item>
2929

3030
<div padding-left padding-right>
@@ -43,15 +43,15 @@
4343

4444
<form (ngSubmit)="submit($event, user)" #lf="ngForm">
4545
<ion-list>
46-
<ion-item clearInput>
46+
<ion-item>
4747
<ion-label floating>Username</ion-label>
4848
<ion-input [(ngModel)]="user.username" ngControl="username" required></ion-input>
4949
</ion-item>
50-
<ion-item clearInput>
50+
<ion-item>
5151
<ion-label floating>Password</ion-label>
5252
<ion-input type="password" [(ngModel)]="user.password" ngControl="password" required></ion-input>
5353
</ion-item>
54-
<div padding-left padding-right clearInput>
54+
<div padding-left padding-right>
5555
<button block type="submit">Login</button>
5656
</div>
5757
<div padding-left>
@@ -64,22 +64,22 @@
6464
</form>
6565

6666
<ion-list>
67-
<ion-item clearInput>
67+
<ion-item>
6868
<ion-label>Email</ion-label>
6969
<ion-input type="email" required></ion-input>
7070
</ion-item>
7171

72-
<ion-item clearInput>
72+
<ion-item>
7373
<ion-label>Username</ion-label>
7474
<ion-input></ion-input>
7575
</ion-item>
7676

77-
<ion-item clearInput>
77+
<ion-item>
7878
<ion-label>Password</ion-label>
7979
<ion-input type="password" required></ion-input>
8080
</ion-item>
8181

82-
<ion-item clearInput>
82+
<ion-item>
8383
<ion-label>Comments</ion-label>
8484
<ion-textarea required>Comment value</ion-textarea>
8585
</ion-item>

0 commit comments

Comments
 (0)