Skip to content

Commit dc1bb4e

Browse files
radium-vCopilot
andcommitted
fix(accordion-item): remove unnecessary id property mappings
Co-authored-by: Copilot <copilot@github.com>
1 parent 8f8f9bf commit dc1bb4e

3 files changed

Lines changed: 7 additions & 32 deletions

File tree

packages/web-components/src/accordion-item/accordion-item.base.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { attr, FASTElement, nullableNumberConverter } from '@microsoft/fast-element';
2-
import { uniqueId } from '@microsoft/fast-web-utilities';
3-
import { toggleState } from '../utils/element-internals.js';
1+
import { attr, FASTElement, nullableNumberConverter, observable } from '@microsoft/fast-element';
42

53
/**
64
*
@@ -58,18 +56,9 @@ export class BaseAccordionItem extends FASTElement {
5856
@attr({ mode: 'boolean' })
5957
public disabled: boolean = false;
6058

61-
/**
62-
* The item ID
63-
*
64-
* @public
65-
* @remarks
66-
* HTML Attribute: id
67-
*/
68-
@attr
69-
public id: string = uniqueId('accordion-');
70-
7159
/**
7260
* @internal
7361
*/
62+
@observable
7463
public expandbutton!: HTMLElement;
7564
}

packages/web-components/src/accordion-item/accordion-item.spec.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,6 @@ test.describe('Accordion item', () => {
116116
await expect(firstItem).toHaveJSProperty('expanded', true);
117117
});
118118

119-
test('should set internal properties to match the id when provided', async ({ fastPage }) => {
120-
const { element } = fastPage;
121-
const button = element.locator('button');
122-
123-
await fastPage.setTemplate(/* html */ `
124-
<fluent-accordion>
125-
<fluent-accordion-item id="foo">Item 1</fluent-accordion-item>
126-
</fluent-accordion>
127-
`);
128-
129-
await expect(element.locator(`[role="region"]`)).toHaveAttribute('aria-labelledby', 'foo');
130-
await expect(button).toHaveId('foo');
131-
});
132-
133119
for (const size of Object.values(AccordionItemSize)) {
134120
test(`should set the \`size\` property to "${size}" when the attribute is set to "${size}"`, async ({
135121
fastPage,

packages/web-components/src/accordion-item/accordion-item.template.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ export function accordionItemTemplate<T extends AccordionItem>(
4141
<button
4242
class="button"
4343
part="button"
44-
${ref('expandbutton')}
45-
?disabled="${x => (x.disabled ? 'true' : void 0)}"
44+
id="control"
45+
aria-controls="panel"
4646
aria-expanded="${x => x.expanded}"
47-
aria-controls="${x => x.id}-panel"
48-
id="${x => x.id}"
47+
?disabled="${x => x.disabled}"
48+
${ref('expandbutton')}
4949
>
5050
<slot name="heading"></slot>
5151
</button>
5252
${startSlotTemplate(options)}
5353
<slot name="marker-expanded"> ${staticallyCompose(options.expandedIcon)} </slot>
5454
<slot name="marker-collapsed"> ${staticallyCompose(options.collapsedIcon)} </slot>
5555
</div>
56-
<div class="content" part="content" id="${x => x.id}-panel" role="region" aria-labelledby="${x => x.id}">
56+
<div class="content" part="content" id="panel" role="region" aria-labelledby="control">
5757
<slot></slot>
5858
</div>
5959
`;

0 commit comments

Comments
 (0)