fix(item): inherit aria attributes before render (#26546)

Resolves #26538
This commit is contained in:
Sean Perkins
2023-01-27 16:02:45 -05:00
committed by GitHub
parent 227b2aea00
commit 95a3c69bbb
5 changed files with 66 additions and 46 deletions

View File

@@ -226,9 +226,12 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
}
}
componentWillLoad() {
this.inheritedAriaAttributes = inheritAttributes(this.el, ['aria-label']);
}
componentDidLoad() {
raf(() => {
this.inheritedAriaAttributes = inheritAttributes(this.el, ['aria-label']);
this.setMultipleInputs();
this.focusable = this.isFocusable();
});

View File

@@ -12,4 +12,17 @@ test.describe('item: axe', () => {
.analyze();
expect(results.violations).toEqual([]);
});
test('should reflect aria-label', async ({ page }) => {
await page.setContent(`
<ion-item id="item-1" aria-label="test"></ion-item>
<ion-item id="item-2" aria-label="test" button="true"></ion-item>
`);
const item1 = await page.locator('#item-1 .item-native');
const item2 = await page.locator('#item-2 .item-native');
expect(await item1.getAttribute('aria-label')).toEqual('test');
expect(await item2.getAttribute('aria-label')).toEqual('test');
});
});