From 9cb5ba7ac1c70c4795eb2732230ffba33a525db4 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 16 Aug 2023 14:51:46 -0400 Subject: [PATCH] Radio button fix (#1524) * fix formatting * fix radio button spacing; fixes #1523 --- docs/pages/resources/changelog.md | 4 ++++ package.json | 16 +++----------- .../button-group/button-group.component.ts | 2 +- .../radio-button/radio-button.test.ts | 22 +++++++++++++++++++ .../radio-group/radio-group.component.ts | 8 ++----- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/docs/pages/resources/changelog.md b/docs/pages/resources/changelog.md index e6b8d8c7..4877bb3a 100644 --- a/docs/pages/resources/changelog.md +++ b/docs/pages/resources/changelog.md @@ -12,6 +12,10 @@ Components with the Experimental bad New versions of Shoelace are released as-needed and generally occur when a critical mass of changes have accumulated. At any time, you can see what's coming in the next release by visiting [next.shoelace.style](https://next.shoelace.style). +## Next + +- Fixed a regression that caused `` to render incorrectly with gaps [#1523] + ## 2.7.0 - Added the experimental `` component [#1473] diff --git a/package.json b/package.json index 00a17ff1..55554f47 100644 --- a/package.json +++ b/package.json @@ -25,15 +25,8 @@ "./dist/react/*": "./dist/react/*", "./dist/translations/*": "./dist/translations/*" }, - "files": [ - "dist", - "cdn" - ], - "keywords": [ - "web components", - "custom elements", - "components" - ], + "files": ["dist", "cdn"], + "keywords": ["web components", "custom elements", "components"], "repository": { "type": "git", "url": "git+https://github.com/shoelace-style/shoelace.git" @@ -140,9 +133,6 @@ "user-agent-data-types": "^0.3.0" }, "lint-staged": { - "*.{ts,js}": [ - "eslint --max-warnings 0 --cache --fix", - "prettier --write" - ] + "*.{ts,js}": ["eslint --max-warnings 0 --cache --fix", "prettier --write"] } } diff --git a/src/components/button-group/button-group.component.ts b/src/components/button-group/button-group.component.ts index 69cd90d9..84328a78 100644 --- a/src/components/button-group/button-group.component.ts +++ b/src/components/button-group/button-group.component.ts @@ -54,7 +54,7 @@ export default class SlButtonGroup extends ShoelaceElement { const index = slottedElements.indexOf(el); const button = findButton(el); - if (button !== null) { + if (button) { button.classList.add('sl-button-group__button'); button.classList.toggle('sl-button-group__button--first', index === 0); button.classList.toggle('sl-button-group__button--inner', index > 0 && index < slottedElements.length - 1); diff --git a/src/components/radio-button/radio-button.test.ts b/src/components/radio-button/radio-button.test.ts index 1a86178c..cea58762 100644 --- a/src/components/radio-button/radio-button.test.ts +++ b/src/components/radio-button/radio-button.test.ts @@ -20,4 +20,26 @@ describe('', () => { expect(radio1.checked).to.be.true; expect(radio2.checked).to.be.false; }); + + it('should receive positional classes from ', async () => { + const radioGroup = await fixture(html` + + + + + + `); + const radio1 = radioGroup.querySelector('#radio-1')!; + const radio2 = radioGroup.querySelector('#radio-2')!; + const radio3 = radioGroup.querySelector('#radio-3')!; + + await Promise.all([radioGroup.updateComplete, radio1.updateComplete, radio2.updateComplete, radio3.updateComplete]); + + expect(radio1.classList.contains('sl-button-group__button')).to.be.true; + expect(radio1.classList.contains('sl-button-group__button--first')).to.be.true; + expect(radio2.classList.contains('sl-button-group__button')).to.be.true; + expect(radio2.classList.contains('sl-button-group__button--inner')).to.be.true; + expect(radio3.classList.contains('sl-button-group__button')).to.be.true; + expect(radio3.classList.contains('sl-button-group__button--last')).to.be.true; + }); }); diff --git a/src/components/radio-group/radio-group.component.ts b/src/components/radio-group/radio-group.component.ts index 96fea508..11210183 100644 --- a/src/components/radio-group/radio-group.component.ts +++ b/src/components/radio-group/radio-group.component.ts @@ -327,11 +327,8 @@ export default class SlRadioGroup extends ShoelaceElement implements ShoelaceFor const hasHelpTextSlot = this.hasSlotController.test('help-text'); const hasLabel = this.label ? true : !!hasLabelSlot; const hasHelpText = this.helpText ? true : !!hasHelpTextSlot; - const defaultSlot = html` - - - + `; return html` @@ -378,7 +375,7 @@ export default class SlRadioGroup extends ShoelaceElement implements ShoelaceFor ${this.hasButtonGroup ? html` - + ${defaultSlot} ` @@ -395,6 +392,5 @@ export default class SlRadioGroup extends ShoelaceElement implements ShoelaceFor `; - /* eslint-enable lit-a11y/click-events-have-key-events */ } }