Skip to content

Commit 8e46414

Browse files
committed
refactor(checkbox): cleanup
1 parent ec4eb83 commit 8e46414

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

core/src/components/checkbox/checkbox.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ComponentInterface, EventEmitter } from '@stencil/core';
2-
import { Component, Element, Event, Host, Method, Prop, State, h, forceUpdate, Build } from '@stencil/core';
2+
import { Component, Element, Event, Host, Method, Prop, State, h, Build } from '@stencil/core';
33
import { checkInvalidState } from '@utils/forms';
44
import type { Attributes } from '@utils/helpers';
55
import { inheritAriaAttributes, renderHiddenInput } from '@utils/helpers';
@@ -186,7 +186,7 @@ export class Checkbox implements ComponentInterface {
186186
}
187187

188188
// Always set initial state
189-
this.isInvalid = this.checkInvalidState();
189+
this.isInvalid = checkInvalidState(el);
190190
}
191191

192192
componentWillLoad() {
@@ -235,13 +235,6 @@ export class Checkbox implements ComponentInterface {
235235
};
236236

237237
private onBlur = () => {
238-
const newIsInvalid = this.checkInvalidState();
239-
if (this.isInvalid !== newIsInvalid) {
240-
this.isInvalid = newIsInvalid;
241-
// Force a re-render to update aria-describedby immediately.
242-
forceUpdate(this);
243-
}
244-
245238
this.ionBlur.emit();
246239
};
247240

@@ -312,16 +305,6 @@ export class Checkbox implements ComponentInterface {
312305
);
313306
}
314307

315-
/**
316-
* Checks if the input is in an invalid state based on Ionic validation classes
317-
*/
318-
private checkInvalidState(): boolean {
319-
const hasIonTouched = this.el.classList.contains('ion-touched');
320-
const hasIonInvalid = this.el.classList.contains('ion-invalid');
321-
322-
return hasIonTouched && hasIonInvalid;
323-
}
324-
325308
render() {
326309
const {
327310
color,

0 commit comments

Comments
 (0)