mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
fix radio group focus bug
This commit is contained in:
@@ -40,6 +40,7 @@ This change applies to all design tokens that implement a color. Refer to the [c
|
||||
- Added CodePen link to code examples
|
||||
- Exposed base and dark stylesheets so they can be imported via JavaScript [#438](https://github.com/shoelace-style/shoelace/issues/438)
|
||||
- Fixed a bug in `sl-menu` where pressing <kbd>Enter</kbd> after using type to select would result in the wrong value
|
||||
- Fixed a bug in `sl-radio-group` where clicking a radio button would cause the wrong control to be focused
|
||||
- Refactored thumb position logic in `sl-switch` [#490](https://github.com/shoelace-style/shoelace/pull/490)
|
||||
- Reworked the dark theme to use an inverted token approach instead of light DOM selectors
|
||||
|
||||
|
||||
@@ -27,14 +27,16 @@ export default class SlRadioGroup extends LitElement {
|
||||
@property({ type: Boolean, attribute: 'no-fieldset' }) noFieldset = false;
|
||||
|
||||
handleFocusIn() {
|
||||
// When focusing into the fieldset, make sure it lands on the checked radio
|
||||
const checkedRadio = [...this.defaultSlot.assignedElements({ flatten: true })].find(
|
||||
el => el.tagName.toLowerCase() === 'sl-radio' && (el as SlRadio).checked
|
||||
) as SlRadio;
|
||||
// When tabbing into the fieldset, make sure it lands on the checked radio
|
||||
requestAnimationFrame(() => {
|
||||
const checkedRadio = [...this.defaultSlot.assignedElements({ flatten: true })].find(
|
||||
el => el.tagName.toLowerCase() === 'sl-radio' && (el as SlRadio).checked
|
||||
) as SlRadio;
|
||||
|
||||
if (checkedRadio) {
|
||||
checkedRadio.focus();
|
||||
}
|
||||
if (checkedRadio) {
|
||||
checkedRadio.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user