|
1 | 1 | import type { ComponentInterface, EventEmitter } from '@stencil/core'; |
2 | 2 | import { Build, Component, Element, Event, Host, Method, Prop, State, Watch, h, forceUpdate } from '@stencil/core'; |
3 | 3 | import type { NotchController } from '@utils/forms'; |
4 | | -import { compareOptions, createNotchController, isOptionSelected } from '@utils/forms'; |
| 4 | +import { compareOptions, createNotchController, isOptionSelected, checkInvalidState } from '@utils/forms'; |
5 | 5 | import { focusVisibleElement, renderHiddenInput, inheritAttributes } from '@utils/helpers'; |
6 | 6 | import type { Attributes } from '@utils/helpers'; |
7 | 7 | import { printIonWarning } from '@utils/logging'; |
@@ -310,7 +310,7 @@ export class Select implements ComponentInterface { |
310 | 310 | // Watch for class changes to update validation state. |
311 | 311 | if (Build.isBrowser && typeof MutationObserver !== 'undefined') { |
312 | 312 | this.validationObserver = new MutationObserver(() => { |
313 | | - const newIsInvalid = this.checkInvalidState(); |
| 313 | + const newIsInvalid = checkInvalidState(this.el); |
314 | 314 | if (this.isInvalid !== newIsInvalid) { |
315 | 315 | this.isInvalid = newIsInvalid; |
316 | 316 | /** |
@@ -342,7 +342,7 @@ export class Select implements ComponentInterface { |
342 | 342 | } |
343 | 343 |
|
344 | 344 | // Always set initial state |
345 | | - this.isInvalid = this.checkInvalidState(); |
| 345 | + this.isInvalid = checkInvalidState(this.el); |
346 | 346 | } |
347 | 347 |
|
348 | 348 | componentWillLoad() { |
@@ -1168,17 +1168,6 @@ export class Select implements ComponentInterface { |
1168 | 1168 | return <div class="select-bottom">{this.renderHintText()}</div>; |
1169 | 1169 | } |
1170 | 1170 |
|
1171 | | - /** |
1172 | | - * Checks if the input is in an invalid state based |
1173 | | - * on Ionic validation classes. |
1174 | | - */ |
1175 | | - private checkInvalidState(): boolean { |
1176 | | - const hasIonTouched = this.el.classList.contains('ion-touched'); |
1177 | | - const hasIonInvalid = this.el.classList.contains('ion-invalid'); |
1178 | | - |
1179 | | - return hasIonTouched && hasIonInvalid; |
1180 | | - } |
1181 | | - |
1182 | 1171 | render() { |
1183 | 1172 | const { |
1184 | 1173 | disabled, |
|
0 commit comments