fix(checkbox, toggle, radio-group): add initial value

This commit is contained in:
Maria Hutt
2025-11-03 15:36:56 -08:00
parent cde3f14c2a
commit 44c635d0a6
6 changed files with 13 additions and 4 deletions

View File

@@ -174,6 +174,7 @@ export class Checkbox implements ComponentInterface {
* a higher priority.
*/
Promise.resolve().then(() => {
console.log('updating hint text id');
this.hintTextID = this.getHintTextID();
});
}
@@ -193,6 +194,8 @@ export class Checkbox implements ComponentInterface {
this.inheritedAttributes = {
...inheritAriaAttributes(this.el),
};
this.hintTextID = this.getHintTextID();
}
disconnectedCallback() {

View File

@@ -146,7 +146,7 @@
const isInvalid = checkbox.classList.contains('ion-invalid');
if (isInvalid) {
console.log('Field marked invalid:', checkbox.label, checkbox.errorText);
console.log('Field marked invalid:', checkbox.innerText, checkbox.errorText);
}
});

View File

@@ -1,7 +1,7 @@
import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Build, Component, Element, Event, Host, Listen, Method, Prop, State, Watch, h } from '@stencil/core';
import { checkInvalidState } from '@utils/forms';
import { renderHiddenInput } from '@utils/helpers';
import { inheritAriaAttributes, renderHiddenInput } from '@utils/helpers';
import { getIonMode } from '../../global/ionic-global';
@@ -171,6 +171,10 @@ export class RadioGroup implements ComponentInterface {
this.isInvalid = checkInvalidState(this.el);
}
componentWillLoad() {
this.hintTextID = this.getHintTextID();
}
disconnectedCallback() {
// Clean up validation observer to prevent memory leaks.
if (this.validationObserver) {

View File

@@ -157,7 +157,7 @@
const isInvalid = radioGroup.classList.contains('ion-invalid');
if (isInvalid) {
console.log('Field marked invalid:', radioGroup.label, radioGroup.errorText);
console.log('Field marked invalid:', radioGroup.id, radioGroup.errorText);
}
});

View File

@@ -146,7 +146,7 @@
const isInvalid = toggle.classList.contains('ion-invalid');
if (isInvalid) {
console.log('Field marked invalid:', toggle.label, toggle.errorText);
console.log('Field marked invalid:', toggle.innerText, toggle.errorText);
}
});

View File

@@ -269,6 +269,8 @@ export class Toggle implements ComponentInterface {
this.inheritedAttributes = {
...inheritAriaAttributes(this.el),
};
this.hintTextID = this.getHintTextID();
}
private onStart() {