From c76f2a25567fe452d9ae33505f57cc9de7dd6cde Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 22 Mar 2021 14:09:03 -0400 Subject: [PATCH] fix(): adding aria-hidden no longer disables automatic rtl switching (#954) --- package-lock.json | 6 +++--- package.json | 2 +- src/components/icon/icon.tsx | 9 ++++++--- src/components/icon/test/icon.spec.ts | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e0a5822..5ad1bdeb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -894,9 +894,9 @@ } }, "@stencil/core": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.4.0.tgz", - "integrity": "sha512-gU6+Yyd6O0KrCSS/O6j8KKqmRo+/Dcs2fI0+APCpbAWK+nqhwDISpdnSEfGDCLMoAC08XOZCycBRk2K1VGnEcg==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.5.0.tgz", + "integrity": "sha512-gpoYJEYzu5LV2hr7uPZklug3zXhEbYGKyNodPfmOOYZtO9q42l7RQ3cAnC8MzEoF4jFrfemgtevGik8sqn9ClQ==" }, "@szmarczak/http-timer": { "version": "4.0.5", diff --git a/package.json b/package.json index 9d709fa2..53268826 100755 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "version": "npm run build" }, "dependencies": { - "@stencil/core": "^2.4.0" + "@stencil/core": "^2.5.0" }, "devDependencies": { "@types/fs-extra": "^9.0.6", diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx index 689fb9fe..ad8353bc 100755 --- a/src/components/icon/icon.tsx +++ b/src/components/icon/icon.tsx @@ -10,6 +10,7 @@ import { getName, getUrl } from './utils'; }) export class Icon { private io?: IntersectionObserver; + private iconName: string | null = null; @Element() el!: HTMLElement; @@ -143,8 +144,9 @@ export class Icon { } } + const label = this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md); + if (!this.ariaLabel && this.ariaHidden !== 'true') { - const label = getName(this.name, this.icon, this.mode, this.ios, this.md); // user did not provide a label // come up with the label based on the icon name if (label) { @@ -154,11 +156,12 @@ export class Icon { } render() { + const { iconName } = this; const mode = this.mode || 'md'; const flipRtl = this.flipRtl || - (this.ariaLabel && - (this.ariaLabel.indexOf('arrow') > -1 || this.ariaLabel.indexOf('chevron') > -1) && + (iconName && + (iconName.indexOf('arrow') > -1 || iconName.indexOf('chevron') > -1) && this.flipRtl !== false); return ( diff --git a/src/components/icon/test/icon.spec.ts b/src/components/icon/test/icon.spec.ts index 657e6807..1332c1ba 100644 --- a/src/components/icon/test/icon.spec.ts +++ b/src/components/icon/test/icon.spec.ts @@ -29,4 +29,20 @@ describe('icon', () => { `); }); + + it('renders rtl with aria-hidden', async () => { + const { root } = await newSpecPage({ + components: [Icon], + direction: 'rtl', + html: ``, + }); + + expect(root).toEqualHtml(` + + `); + }); });