Skip to content

Commit

Permalink
fix(input): remove old clearInput code and clean up UI, added onChang…
Browse files Browse the repository at this point in the history
…e calls

references #6514
  • Loading branch information
brandyscarney committed May 12, 2016
1 parent 619f119 commit 71cd297
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
8 changes: 0 additions & 8 deletions ionic/components/input/input-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,6 @@ export class InputBase {
}
}

/**
* @private
*/
clearTextInput() {
console.debug('Should clear input');
this._value = '';
}

/**
* @private
*/
Expand Down
1 change: 1 addition & 0 deletions ionic/components/input/input.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ ion-input[clearInput] {
bottom: 0;

width: $text-input-ios-input-clear-icon-width;
height: 34px;

background-size: $text-input-ios-input-clear-icon-size;
}
2 changes: 1 addition & 1 deletion ionic/components/input/input.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ion-input[clearInput] {
@include svg-background-image($text-input-md-input-clear-icon-svg);

right: ($item-md-padding-right / 2);
bottom: 2px;
bottom: 4px;

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

Expand Down
5 changes: 5 additions & 0 deletions ionic/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ input.text-input:-webkit-autofill {

.text-input-clear-icon {
position: absolute;
display: none;

margin: 0;
padding: 0;
Expand All @@ -135,6 +136,10 @@ input.text-input:-webkit-autofill {
background-position: center;
}

.input-has-value .text-input-clear-icon {
display: block;
}


// Cloned Input
// --------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion ionic/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import {Platform} from '../../platform/platform';
template:
'<input [type]="type" [(ngModel)]="_value" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" [placeholder]="placeholder" class="text-input">' +
'<input [type]="type" aria-hidden="true" next-input *ngIf="_useAssist">' +
'<button clear *ngIf="clearInput && value" type="button" class="text-input-clear-icon" (click)="clearTextInput()" (mousedown)="clearTextInput()"></button>' +
'<button clear [hidden]="!clearInput" type="button" class="text-input-clear-icon" (click)="clearTextInput()" (mousedown)="clearTextInput()"></button>' +
'<div (touchstart)="pointerStart($event)" (touchend)="pointerEnd($event)" (mousedown)="pointerStart($event)" (mouseup)="pointerEnd($event)" class="input-cover" tappable *ngIf="_useAssist"></div>',
directives: [
NextInput,
Expand Down Expand Up @@ -107,7 +107,10 @@ export class TextInput extends InputBase {
* @private
*/
clearTextInput() {
console.debug("Should clear input");
this._value = '';
this.onChange(this._value);
this.writeValue(this._value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ionic/components/input/input.wp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ion-input[clearInput] {
@include svg-background-image($text-input-wp-input-clear-icon-svg);

right: ($item-wp-padding-right / 2);
bottom: 2px;
bottom: 7px;

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

Expand Down
30 changes: 15 additions & 15 deletions ionic/components/input/test/form-inputs/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
<form [ngFormModel]="loginForm" #mf="ngForm" novalidate>

<ion-list>
<ion-item clearInput>
<ion-item>
<ion-label floating>Email</ion-label>
<ion-input [(ngModel)]="login.email" ngControl="email" type="email" required></ion-input>
<ion-input clearInput [(ngModel)]="login.email" ngControl="email" type="email" required></ion-input>
</ion-item>

<ion-item clearInput>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input [(ngModel)]="login.username" ngControl="username"></ion-input>
<ion-input clearInput [(ngModel)]="login.username" ngControl="username"></ion-input>
</ion-item>

<ion-item clearInput>
<ion-item>
<ion-label>Password</ion-label>
<ion-input [(ngModel)]="login.password" ngControl="password" type="password" required></ion-input>
<ion-input clearInput [(ngModel)]="login.password" ngControl="password" type="password" required></ion-input>
</ion-item>

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

<div padding-left padding-right>
Expand All @@ -43,15 +43,15 @@

<form (ngSubmit)="submit($event, user)" #lf="ngForm">
<ion-list>
<ion-item clearInput>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input [(ngModel)]="user.username" ngControl="username" required></ion-input>
</ion-item>
<ion-item clearInput>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input type="password" [(ngModel)]="user.password" ngControl="password" required></ion-input>
</ion-item>
<div padding-left padding-right clearInput>
<div padding-left padding-right>
<button block type="submit">Login</button>
</div>
<div padding-left>
Expand All @@ -64,22 +64,22 @@
</form>

<ion-list>
<ion-item clearInput>
<ion-item>
<ion-label>Email</ion-label>
<ion-input type="email" required></ion-input>
</ion-item>

<ion-item clearInput>
<ion-item>
<ion-label>Username</ion-label>
<ion-input></ion-input>
</ion-item>

<ion-item clearInput>
<ion-item>
<ion-label>Password</ion-label>
<ion-input type="password" required></ion-input>
</ion-item>

<ion-item clearInput>
<ion-item>
<ion-label>Comments</ion-label>
<ion-textarea required>Comment value</ion-textarea>
</ion-item>
Expand Down

0 comments on commit 71cd297

Please sign in to comment.