mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
fix(input): pass readonly from ion-input down to native input
also adds to placeholder test an input and textarea with readonly that can be toggled fixes #6408
This commit is contained in:

committed by
Adam Bradley

parent
7a6ba2d300
commit
f9a576ed93
@ -80,8 +80,8 @@ import { Platform } from '../../platform/platform';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'ion-input,ion-textarea',
|
selector: 'ion-input,ion-textarea',
|
||||||
template:
|
template:
|
||||||
'<input [(ngModel)]="_value" [type]="type" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" [placeholder]="placeholder" [disabled]="disabled" class="text-input" [ngClass]="\'text-input-\' + _mode" *ngIf="_type!==\'textarea\'" #input>' +
|
'<input [(ngModel)]="_value" [type]="type" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" [placeholder]="placeholder" [disabled]="disabled" [readonly]="readonly" class="text-input" [ngClass]="\'text-input-\' + _mode" *ngIf="_type!==\'textarea\'" #input>' +
|
||||||
'<textarea [(ngModel)]="_value" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" [placeholder]="placeholder" [disabled]="disabled" class="text-input" [ngClass]="\'text-input-\' + _mode" *ngIf="_type===\'textarea\'" #textarea></textarea>' +
|
'<textarea [(ngModel)]="_value" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" [placeholder]="placeholder" [disabled]="disabled" [readonly]="readonly" class="text-input" [ngClass]="\'text-input-\' + _mode" *ngIf="_type===\'textarea\'" #textarea></textarea>' +
|
||||||
'<input [type]="type" aria-hidden="true" next-input *ngIf="_useAssist">' +
|
'<input [type]="type" aria-hidden="true" next-input *ngIf="_useAssist">' +
|
||||||
'<button ion-button clear [hidden]="!clearInput" type="button" class="text-input-clear-icon" (click)="clearTextInput()" (mousedown)="clearTextInput()"></button>' +
|
'<button ion-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>',
|
'<div (touchstart)="pointerStart($event)" (touchend)="pointerEnd($event)" (mousedown)="pointerStart($event)" (mouseup)="pointerEnd($event)" class="input-cover" tappable *ngIf="_useAssist"></div>',
|
||||||
@ -96,6 +96,7 @@ export class TextInput extends Ion implements IonicFormInput {
|
|||||||
_coord: PointerCoordinates;
|
_coord: PointerCoordinates;
|
||||||
_didBlurAfterEdit: boolean;
|
_didBlurAfterEdit: boolean;
|
||||||
_disabled: boolean = false;
|
_disabled: boolean = false;
|
||||||
|
_readonly: boolean = false;
|
||||||
_isTouch: boolean;
|
_isTouch: boolean;
|
||||||
_keyboardHeight: number;
|
_keyboardHeight: number;
|
||||||
_native: NativeInput;
|
_native: NativeInput;
|
||||||
@ -164,7 +165,7 @@ export class TextInput extends Ion implements IonicFormInput {
|
|||||||
@Input() placeholder: string = '';
|
@Input() placeholder: string = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @input {bool} A clear icon will appear in the input when there is a value. Clicking it clears the input.
|
* @input {boolean} A clear icon will appear in the input when there is a value. Clicking it clears the input.
|
||||||
*/
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
get clearInput() {
|
get clearInput() {
|
||||||
@ -208,7 +209,7 @@ export class TextInput extends Ion implements IonicFormInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @input {bool} If the input should be disabled or not
|
* @input {boolean} If the input should be disabled or not
|
||||||
*/
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
get disabled() {
|
get disabled() {
|
||||||
@ -226,6 +227,17 @@ export class TextInput extends Ion implements IonicFormInput {
|
|||||||
this._native && this._native.isDisabled(val);
|
this._native && this._native.isDisabled(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @input {boolean} If the input should be readonly or not
|
||||||
|
*/
|
||||||
|
@Input()
|
||||||
|
get readonly() {
|
||||||
|
return this._readonly;
|
||||||
|
}
|
||||||
|
set readonly(val: boolean) {
|
||||||
|
this._readonly = isTrueProperty(val);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @input {string} The mode to apply to this component.
|
* @input {string} The mode to apply to this component.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,14 @@ import { IonicApp, IonicModule } from '../../../../../ionic-angular';
|
|||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'main.html'
|
templateUrl: 'main.html'
|
||||||
})
|
})
|
||||||
export class E2EPage {}
|
export class E2EPage {
|
||||||
|
isReadonly: boolean = true;
|
||||||
|
|
||||||
|
toggleReadonly() {
|
||||||
|
this.isReadonly = !this.isReadonly;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
<ion-toolbar>
|
<ion-toolbar>
|
||||||
<ion-title>Placeholder Label Text Input</ion-title>
|
<ion-title>Placeholder Label Text Input</ion-title>
|
||||||
|
<ion-buttons end>
|
||||||
|
<button ion-button (click)="toggleReadonly()">Toggle</button>
|
||||||
|
</ion-buttons>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
|
||||||
</ion-header>
|
</ion-header>
|
||||||
@ -19,6 +22,10 @@
|
|||||||
<ion-input placeholder="Text Input Placeholder" value="Text Input Value"></ion-input>
|
<ion-input placeholder="Text Input Placeholder" value="Text Input Value"></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-input placeholder="Text Input Readonly" [readonly]="isReadonly" value="Text Input Readonly"></ion-input>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-icon name="call" item-left></ion-icon>
|
<ion-icon name="call" item-left></ion-icon>
|
||||||
<ion-input placeholder="Text Input Placeholder"></ion-input>
|
<ion-input placeholder="Text Input Placeholder"></ion-input>
|
||||||
@ -37,6 +44,10 @@
|
|||||||
<ion-textarea placeholder="ion-textarea Placeholder" value="Textarea value"></ion-textarea>
|
<ion-textarea placeholder="ion-textarea Placeholder" value="Textarea value"></ion-textarea>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-textarea placeholder="ion-textarea Readonly" [readonly]="isReadonly" value="Textarea Readonly"></ion-textarea>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
||||||
<ion-list inset>
|
<ion-list inset>
|
||||||
|
Reference in New Issue
Block a user