fix checkbox required label in Chrome

See https://bugs.chromium.org/p/chromium/issues/detail?id=1413733
pull/1186/head
Cory LaViska 2023-02-07 10:52:54 -05:00
rodzic 776ab2c715
commit f03de8925b
2 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -16,6 +16,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti
- Fixed a bug in `<sl-checkbox>` and `<sl-switch>` that caused the browser to scroll incorrectly when focusing on a control in a container with overflow [#1169](https://github.com/shoelace-style/shoelace/issues/1169)
- Fixed a bug in `<sl-menu-item>` that caused the `click` event to be emitted when the item was disabled [#1113](https://github.com/shoelace-style/shoelace/issues/1113)
- Fixed a bug in form controls that erroneously prevented validation states from being set when `novalidate` was used on the containing form [#1164](https://github.com/shoelace-style/shoelace/issues/1164)
- Fixed a bug in `<sl-checkbox>` that caused the required asterisk to appear before the label in Chrome
- Improved the behavior of `<sl-dropdown>` in Safari so keyboard interaction works the same as in other browsers [#1177](https://github.com/shoelace-style/shoelace/issues/1177)
- Improved the [icons](/components/icon) page so it's not as sluggish in Safari [#1122](https://github.com/shoelace-style/shoelace/issues/1122)
- Improved the accessibility of `<sl-switch>` when used in forced-colors / Windows High Contrast mode [#1114](https://github.com/shoelace-style/shoelace/issues/1114)

Wyświetl plik

@ -157,6 +157,11 @@ export default class SlCheckbox extends ShoelaceElement implements ShoelaceFormC
}
render() {
//
// NOTE: we use a <div> around the label slot because of this Chrome bug.
//
// https://bugs.chromium.org/p/chromium/issues/detail?id=1413733
//
return html`
<label
part="base"
@ -209,7 +214,9 @@ export default class SlCheckbox extends ShoelaceElement implements ShoelaceFormC
: ''}
</span>
<slot part="label" class="checkbox__label"></slot>
<div part="label" class="checkbox__label">
<slot></slot>
</div>
</label>
`;
}