diff --git a/packages/webawesome/docs/docs/resources/changelog.md b/packages/webawesome/docs/docs/resources/changelog.md index 6556ad423..c5ae7264e 100644 --- a/packages/webawesome/docs/docs/resources/changelog.md +++ b/packages/webawesome/docs/docs/resources/changelog.md @@ -18,6 +18,7 @@ Components with the Experimental badge sh - Fixed a bug in `` where slotted badges weren't properly positioned in buttons with an `href` [issue:1377] - Fixed focus outline styles in `` and native `
` [issue:1456] - Fixed focus outline styles in ``, ``, and `` [issue:1484] +- Fixed a bug in `` where its value would revert to `""` when checked / unchecked [pr:1547] - Fixed a bug that caused icon button labels to not render in frameworks [issue:1542] - Fixed a bug in `` that caused the `name` property not to reflect [pr:1538] @@ -463,4 +464,4 @@ Many of these changes and improvements were the direct result of feedback from u
-Did we miss something? [Let us know!](https://github.com/shoelace-style/webawesome/discussions) +Did we miss something? [Let us know!](https://github.com/shoelace-style/webawesome/discussions) \ No newline at end of file diff --git a/packages/webawesome/src/components/checkbox/checkbox.test.ts b/packages/webawesome/src/components/checkbox/checkbox.test.ts index fc607b68b..df3c90c07 100644 --- a/packages/webawesome/src/components/checkbox/checkbox.test.ts +++ b/packages/webawesome/src/components/checkbox/checkbox.test.ts @@ -21,7 +21,7 @@ describe('', () => { const el = await fixture(html` `); expect(el.name).to.equal(''); - expect(el.value).to.equal('on'); + expect(el.value).to.equal(null); expect(el.title).to.equal(''); expect(el.disabled).to.be.false; expect(el.required).to.be.false; @@ -134,7 +134,7 @@ describe('', () => { await checkbox.updateComplete; expect(checkbox.checked).to.equal(false); - expect(checkbox.value).to.equal('myvalue'); + expect(checkbox.value).to.equal(null); expect(new FormData(form).get('test')).to.equal(null); checkbox.checked = true; diff --git a/packages/webawesome/src/components/checkbox/checkbox.ts b/packages/webawesome/src/components/checkbox/checkbox.ts index 7b6ae9e43..1f1decf62 100644 --- a/packages/webawesome/src/components/checkbox/checkbox.ts +++ b/packages/webawesome/src/components/checkbox/checkbox.ts @@ -80,7 +80,8 @@ export default class WaCheckbox extends WebAwesomeFormAssociatedElement { /** The value of the checkbox, submitted as a name/value pair with form data. */ get value(): string | null { - return this._value ?? 'on'; + const val = this._value || 'on'; + return this.checked ? val : null; } @property({ reflect: true })