add click method

This commit is contained in:
Cory LaViska
2021-04-01 08:40:48 -04:00
parent 619758cbc3
commit 784c173728
5 changed files with 16 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ _During the beta period, these restrictions may be relaxed in the event of a mis
## Next
- Added `click()` method to `sl-checkbox`, `sl-radio`, and `sl-switch`
- Fixed a bug in `sl-tooltip` where events weren't properly cleaned up on disconnect
- Fixed a bug in `sl-tooltip` where they wouldn't display after toggling `disabled` off and on again [#391](https://github.com/shoelace-style/shoelace/issues/391)
- Improved a11y for disabled buttons that are rendered as links

View File

@@ -86,7 +86,6 @@ export default class SlButton extends LitElement {
/** Simulates a click on the button. */
click() {
this.button.focus();
this.button.click();
}

View File

@@ -63,6 +63,11 @@ export default class SlCheckbox extends LitElement {
this.input.indeterminate = this.indeterminate;
}
/** Simulates a click on the checkbox. */
click() {
this.input.click();
}
/** Sets focus on the checkbox. */
focus(options?: FocusOptions) {
this.input.focus(options);

View File

@@ -55,6 +55,11 @@ export default class SlRadio extends LitElement {
/** Emitted when the control gains focus. */
@event('sl-focus') slFocus: EventEmitter<void>;
/** Simulates a click on the radio. */
click() {
this.input.click();
}
/** Sets focus on the radio. */
focus(options?: FocusOptions) {
this.input.focus(options);

View File

@@ -55,6 +55,11 @@ export default class SlSwitch extends LitElement {
/** Emitted when the control gains focus. */
@event('sl-focus') slFocus: EventEmitter<void>;
/** Simulates a click on the switch. */
click() {
this.input.click();
}
/** Sets focus on the switch. */
focus(options?: FocusOptions) {
this.input.focus(options);