Skip to content

Commit df8fa7d

Browse files
committed
refactor(input): removing angular-specific code from core
1 parent 65867ce commit df8fa7d

File tree

2 files changed

+4
-46
lines changed

2 files changed

+4
-46
lines changed

core/src/components/input/input.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -404,21 +404,13 @@ export class Input implements ComponentInterface {
404404
}
405405

406406
/**
407-
* Checks if the input is in an invalid state based on validation classes
407+
* Checks if the input is in an invalid state based on Ionic validation classes
408408
*/
409409
private checkValidationState(): boolean {
410-
// Check for both Ionic and Angular validation classes on the element itself
411-
// Angular applies ng-touched/ng-invalid directly to the host element with ngModel
412410
const hasIonTouched = this.el.classList.contains('ion-touched');
413411
const hasIonInvalid = this.el.classList.contains('ion-invalid');
414-
const hasNgTouched = this.el.classList.contains('ng-touched');
415-
const hasNgInvalid = this.el.classList.contains('ng-invalid');
416412

417-
// Return true if we have both touched and invalid states from either framework
418-
const isTouched = hasIonTouched || hasNgTouched;
419-
const isInvalid = hasIonInvalid || hasNgInvalid;
420-
421-
return isTouched && isInvalid;
413+
return hasIonTouched && hasIonInvalid;
422414
}
423415

424416
connectedCallback() {
@@ -601,19 +593,6 @@ export class Input implements ComponentInterface {
601593

602594
this.ionBlur.emit(ev);
603595

604-
/**
605-
* Check validation state after blur to handle framework-managed classes.
606-
* Frameworks like Angular update classes asynchronously, often using
607-
* requestAnimationFrame or promises. Using setTimeout ensures we check
608-
* after all microtasks and animation frames have completed.
609-
*/
610-
setTimeout(() => {
611-
const newIsInvalid = this.checkValidationState();
612-
if (this.isInvalid !== newIsInvalid) {
613-
this.isInvalid = newIsInvalid;
614-
forceUpdate(this);
615-
}
616-
}, 100);
617596
};
618597

619598
private onFocus = (ev: FocusEvent) => {

core/src/components/textarea/textarea.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,13 @@ export class Textarea implements ComponentInterface {
336336
}
337337

338338
/**
339-
* Checks if the textarea is in an invalid state based on validation classes
339+
* Checks if the textarea is in an invalid state based on Ionic validation classes
340340
*/
341341
private checkValidationState(): boolean {
342-
// Check for both Ionic and Angular validation classes on the element itself
343-
// Angular applies ng-touched/ng-invalid directly to the host element with ngModel
344342
const hasIonTouched = this.el.classList.contains('ion-touched');
345343
const hasIonInvalid = this.el.classList.contains('ion-invalid');
346-
const hasNgTouched = this.el.classList.contains('ng-touched');
347-
const hasNgInvalid = this.el.classList.contains('ng-invalid');
348344

349-
// Return true if we have both touched and invalid states from either framework
350-
const isTouched = hasIonTouched || hasNgTouched;
351-
const isInvalid = hasIonInvalid || hasNgInvalid;
352-
353-
return isTouched && isInvalid;
345+
return hasIonTouched && hasIonInvalid;
354346
}
355347

356348
connectedCallback() {
@@ -586,19 +578,6 @@ export class Textarea implements ComponentInterface {
586578
this.didTextareaClearOnEdit = false;
587579
this.ionBlur.emit(ev);
588580

589-
/**
590-
* Check validation state after blur to handle framework-managed classes.
591-
* Frameworks like Angular update classes asynchronously, often using
592-
* requestAnimationFrame or promises. Using setTimeout ensures we check
593-
* after all microtasks and animation frames have completed.
594-
*/
595-
setTimeout(() => {
596-
const newIsInvalid = this.checkValidationState();
597-
if (this.isInvalid !== newIsInvalid) {
598-
this.isInvalid = newIsInvalid;
599-
forceUpdate(this);
600-
}
601-
}, 100);
602581
};
603582

604583
private onKeyDown = (ev: KeyboardEvent) => {

0 commit comments

Comments
 (0)