@timmo001/groundwork-ui 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +1 -1
- package/package.json +1 -1
- package/src/gw-button.ts +20 -1
package/custom-elements.json
CHANGED
|
@@ -3613,7 +3613,7 @@
|
|
|
3613
3613
|
"type": {
|
|
3614
3614
|
"text": "\"button\"|\"submit\"|\"reset\""
|
|
3615
3615
|
},
|
|
3616
|
-
"description": "
|
|
3616
|
+
"description": "What a click does: nothing more, or submit or reset the form the button is in. Defaults to `button`.",
|
|
3617
3617
|
"name": "type"
|
|
3618
3618
|
},
|
|
3619
3619
|
{
|
package/package.json
CHANGED
package/src/gw-button.ts
CHANGED
|
@@ -32,7 +32,7 @@ import { base, controlSizes, createIcon, setIconPath } from "./styles.js";
|
|
|
32
32
|
* @attr {"brand"|"neutral"|"info"|"success"|"warning"|"danger"} variant - The color. Defaults to `brand`.
|
|
33
33
|
* @attr {"accent"|"filled"|"outlined"|"plain"} appearance - How the color is applied. Defaults to `accent`.
|
|
34
34
|
* @attr {"xs"|"small"|"medium"|"large"|"xl"} size - The size, 24 to 56px tall. Defaults to `medium`.
|
|
35
|
-
* @attr {"button"|"submit"|"reset"} type -
|
|
35
|
+
* @attr {"button"|"submit"|"reset"} type - What a click does: nothing more, or submit or reset the form the button is in. Defaults to `button`.
|
|
36
36
|
* @attr {string} href - Renders a link to this address instead of a button.
|
|
37
37
|
* @attr {string} label - The accessible name, when the text alone isn't enough.
|
|
38
38
|
* @attr {boolean} disabled - Disables the button.
|
|
@@ -423,6 +423,25 @@ export class GwButton extends GwElement {
|
|
|
423
423
|
if (link !== null && !event.composedPath().includes(link)) {
|
|
424
424
|
link.click();
|
|
425
425
|
}
|
|
426
|
+
|
|
427
|
+
// The native button is in the shadow root, so it has no form of its
|
|
428
|
+
// own; submit and reset act on the form around the element instead
|
|
429
|
+
const form = this.closest("form");
|
|
430
|
+
|
|
431
|
+
if (
|
|
432
|
+
form === null ||
|
|
433
|
+
this.disabled ||
|
|
434
|
+
event.defaultPrevented ||
|
|
435
|
+
!(this.#control instanceof HTMLButtonElement)
|
|
436
|
+
) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (this.type === "submit") {
|
|
441
|
+
form.requestSubmit();
|
|
442
|
+
} else if (this.type === "reset") {
|
|
443
|
+
form.reset();
|
|
444
|
+
}
|
|
426
445
|
});
|
|
427
446
|
|
|
428
447
|
const focus = () => {
|