From e6aecfbf028b82b018b0371b250cf7410a5b1a77 Mon Sep 17 00:00:00 2001 From: personal Date: Thu, 12 Dec 2024 12:45:23 +0000 Subject: [PATCH] use @query for fieldset --- packages/components/pie-radio-group/src/index.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/components/pie-radio-group/src/index.ts b/packages/components/pie-radio-group/src/index.ts index b2b48add9e..72e8b6c0fb 100644 --- a/packages/components/pie-radio-group/src/index.ts +++ b/packages/components/pie-radio-group/src/index.ts @@ -6,7 +6,9 @@ import { type PropertyValues, type TemplateResult, } from 'lit'; -import { property, queryAssignedElements, state } from 'lit/decorators.js'; +import { + property, query, queryAssignedElements, state, +} from 'lit/decorators.js'; import { RtlMixin, defineCustomElement, @@ -63,6 +65,9 @@ export class PieRadioGroup extends FormControlMixin(RtlMixin(LitElement)) implem @queryAssignedElements({ selector: 'pie-radio' }) _slottedChildren!: Array; + @query('fieldset') + private _fieldset!: HTMLInputElement; + private _abortController!: AbortController; /** @@ -261,13 +266,10 @@ export class PieRadioGroup extends FormControlMixin(RtlMixin(LitElement)) implem * @param {boolean} enable - Whether to enable (`true`) or disable (`false`) the `tabindex` on the `fieldset`. */ private _toggleFieldsetTabindex (enable: boolean): void { - const fieldset = this.shadowRoot?.querySelector('fieldset'); - - if (!fieldset) return; if (enable) { - fieldset.setAttribute('tabindex', '0'); + this._fieldset.setAttribute('tabindex', '0'); } else { - fieldset.removeAttribute('tabindex'); + this._fieldset.removeAttribute('tabindex'); } }