kopia lustrzana https://github.com/shoelace-style/shoelace
Fix getter
rodzic
6eb79aacdb
commit
cfa800c1cd
|
@ -24,6 +24,14 @@ export default class SlRadioGroup extends LitElement {
|
|||
/** The radio group label. Required for proper accessibility. Alternatively, you can use the label slot. */
|
||||
@property() label = '';
|
||||
|
||||
/** The current value of the radio group. */
|
||||
@property()
|
||||
get value() {
|
||||
if (!this._value) return this.getCurrentValue();
|
||||
|
||||
return this._value;
|
||||
}
|
||||
|
||||
set value(newValue) {
|
||||
const index = this.getAllRadios().findIndex(el => el.value === newValue);
|
||||
const oldValue = this._value;
|
||||
|
@ -38,12 +46,6 @@ export default class SlRadioGroup extends LitElement {
|
|||
}
|
||||
}
|
||||
|
||||
/** The current value of the radio group. */
|
||||
@property()
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
/** Shows the fieldset and legend that surrounds the radio group. */
|
||||
@property({ type: Boolean, attribute: 'fieldset' }) fieldset = false;
|
||||
|
||||
|
@ -66,6 +68,12 @@ export default class SlRadioGroup extends LitElement {
|
|||
});
|
||||
}
|
||||
|
||||
getCurrentValue() {
|
||||
const valRadio = this.getAllRadios().filter(el => el.checked);
|
||||
this._value = valRadio.length === 1 ? valRadio[0].value : '';
|
||||
return this._value;
|
||||
}
|
||||
|
||||
handleFocusIn() {
|
||||
// When tabbing into the fieldset, make sure it lands on the checked radio
|
||||
requestAnimationFrame(() => {
|
||||
|
|
Ładowanie…
Reference in New Issue