From e63dbc16f9eec9fd35e9a5146a984be3035a89b7 Mon Sep 17 00:00:00 2001 From: felix-ico <97440128+felix-ico@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:26:04 +0100 Subject: [PATCH] fix: remove unnecessary prop, add required aria attribute (#2192) --- .../chip/__snapshots__/chip.spec.ts.snap | 2 +- .../components/src/components/chip/chip.tsx | 19 ++++++++++------ .../components/src/components/chip/readme.md | 22 +++++++++---------- .../stories/components/chip/ScaleChip.vue | 2 +- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/packages/components/src/components/chip/__snapshots__/chip.spec.ts.snap b/packages/components/src/components/chip/__snapshots__/chip.spec.ts.snap index 95f6118f16..e597051eff 100644 --- a/packages/components/src/components/chip/__snapshots__/chip.spec.ts.snap +++ b/packages/components/src/components/chip/__snapshots__/chip.spec.ts.snap @@ -3,7 +3,7 @@ exports[`Chip should match snapshot 1`] = ` - + diff --git a/packages/components/src/components/chip/chip.tsx b/packages/components/src/components/chip/chip.tsx index d9dc262856..53e9209561 100644 --- a/packages/components/src/components/chip/chip.tsx +++ b/packages/components/src/components/chip/chip.tsx @@ -34,9 +34,15 @@ export class Chip { /** (optional) */ @Prop() selected?: boolean = false; /** (optional) chip aria-role */ - @Prop() ariaRoleTitle?: string; - /** (optional) chip aria-checked */ - @Prop() ariaCheckedState?: boolean; + @Prop() ariaRoleTitle?: + | 'switch' + | 'radio' + | 'option' + | 'menuitemreadio' + | 'menuitemcheckbox' + | 'checkbox' = 'switch'; + /** @deprecated (optional) chip aria-checked - should be derived from selected state attribute */ + @Prop() ariaCheckedState?: boolean = false; /** (optional) chip label */ @Prop() label?: string; /** (optional) chip disabled */ @@ -140,6 +146,7 @@ export class Chip { tabindex={this.selected ? '0' : '-1'} part={this.getBasePartMap()} class={this.getCssClassMap()} + aria-checked={this.selected.toString()} onClick={ !this.disabled || this.type === 'dynamic' ? this.handleClick @@ -154,10 +161,8 @@ export class Chip { ) : ( **[DEPRECATED]** (optional) chip aria-checked - should be derived from selected state attribute

| `boolean` | `false` | +| `ariaRoleTitle` | `aria-role-title` | (optional) chip aria-role | `"checkbox" \| "menuitemcheckbox" \| "menuitemreadio" \| "option" \| "radio" \| "switch"` | `'switch'` | +| `disabled` | `disabled` | (optional) chip disabled | `boolean` | `false` | +| `dismissText` | `dismiss-text` | (optional) Dismiss label | `string` | `'dismiss'` | +| `label` | `label` | (optional) chip label | `string` | `undefined` | +| `selected` | `selected` | (optional) | `boolean` | `false` | +| `styles` | `styles` | (optional) Injected CSS styles | `string` | `undefined` | +| `type` | `type` | (optional) | `"dynamic" \| "persistent"` | `'persistent'` | +| `variant` | `variant` | (optional) | `"outline" \| "standard"` | `'standard'` | ## Events diff --git a/packages/storybook-vue/stories/components/chip/ScaleChip.vue b/packages/storybook-vue/stories/components/chip/ScaleChip.vue index c7964a243f..e6cb20023c 100644 --- a/packages/storybook-vue/stories/components/chip/ScaleChip.vue +++ b/packages/storybook-vue/stories/components/chip/ScaleChip.vue @@ -23,7 +23,7 @@ export default { variant: { type: 'standard' | 'outline', default: 'standard' }, selected: { type: Boolean, default: false }, disabled: { type: Boolean, default: false }, - styles: { type: String }, + styles: { type: 'switch' | 'radio' | 'option' | 'menuitemreadio' | 'menuitemcheckbox' | 'checkbox', default: 'switch'}, ariaRoleTitle: { type: String }, ariaCheckedState: { type: Boolean }, },