mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(textarea): ionChange will only emit from user committed changes (#25953)
This commit is contained in:
18
angular/test/base/e2e/src/textarea.spec.ts
Normal file
18
angular/test/base/e2e/src/textarea.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
describe('Textarea', () => {
|
||||
beforeEach(() => cy.visit('/textarea'));
|
||||
|
||||
it('should become valid', () => {
|
||||
cy.get('#status').should('have.text', 'INVALID');
|
||||
|
||||
cy.get('ion-textarea').type('hello');
|
||||
|
||||
cy.get('#status').should('have.text', 'VALID');
|
||||
});
|
||||
|
||||
it('should update the form control value when typing', () => {
|
||||
cy.get('#value').contains(`"textarea": ""`);
|
||||
cy.get('ion-textarea').type('hello');
|
||||
|
||||
cy.get('#value').contains(`"textarea": "hello"`);
|
||||
});
|
||||
});
|
||||
@@ -25,6 +25,7 @@ const routes: Routes = [
|
||||
{ path: 'accordions', component: AccordionComponent },
|
||||
{ path: 'alerts', component: AlertComponent },
|
||||
{ path: 'inputs', component: InputsComponent },
|
||||
{ path: 'textarea', loadChildren: () => import('./textarea/textarea.module').then(m => m.TextareaModule) },
|
||||
{ path: 'form', component: FormComponent },
|
||||
{ path: 'modals', component: ModalComponent },
|
||||
{ path: 'modal-inline', loadChildren: () => import('./modal-inline').then(m => m.ModalInlineModule) },
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
Form Status: <span id="status">{{ profileForm.status }}</span>
|
||||
</p>
|
||||
<p>
|
||||
Form Status: <span id="data">{{ profileForm.value | json }}</span>
|
||||
Form value: <span id="data">{{ profileForm.value | json }}</span>
|
||||
</p>
|
||||
<p>
|
||||
Form Submit: <span id="submit">{{submitted}}</span>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
import { RouterModule } from "@angular/router";
|
||||
import { TextareaComponent } from "./textarea.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: TextareaComponent
|
||||
}
|
||||
])
|
||||
],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class TextareaRoutingModule { }
|
||||
16
angular/test/base/src/app/textarea/textarea.component.html
Normal file
16
angular/test/base/src/app/textarea/textarea.component.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<ion-content>
|
||||
<form [formGroup]="form">
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
<ion-label>Textarea</ion-label>
|
||||
<ion-textarea formControlName="textarea"></ion-textarea>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</form>
|
||||
<p>
|
||||
Form status: <span id="status">{{ form.status }}</span>
|
||||
</p>
|
||||
<p>
|
||||
Form value: <span id="value">{{ form.value | json }}</span>
|
||||
</p>
|
||||
</ion-content>
|
||||
17
angular/test/base/src/app/textarea/textarea.component.ts
Normal file
17
angular/test/base/src/app/textarea/textarea.component.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-textarea',
|
||||
templateUrl: 'textarea.component.html',
|
||||
})
|
||||
export class TextareaComponent {
|
||||
|
||||
form = this.fb.group({
|
||||
textarea: ['', Validators.required]
|
||||
})
|
||||
|
||||
constructor(private fb: FormBuilder) { }
|
||||
|
||||
}
|
||||
21
angular/test/base/src/app/textarea/textarea.module.ts
Normal file
21
angular/test/base/src/app/textarea/textarea.module.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { NgModule } from "@angular/core";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
import { IonicModule } from "@ionic/angular";
|
||||
|
||||
import { TextareaRoutingModule } from "./textarea-routing.module";
|
||||
import { TextareaComponent } from "./textarea.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
IonicModule,
|
||||
TextareaRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
TextareaComponent
|
||||
]
|
||||
})
|
||||
export class TextareaModule { }
|
||||
Reference in New Issue
Block a user