From fdedcf289490209963794e83aa28ca07fb966583 Mon Sep 17 00:00:00 2001 From: Joren Broekema Date: Tue, 12 Nov 2019 16:31:22 +0100 Subject: [PATCH] fix(button): make button more accessible --- packages/button/src/LionButton.js | 3 ++- packages/button/test/lion-button.test.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/button/src/LionButton.js b/packages/button/src/LionButton.js index 5f92bb082..d34b22375 100644 --- a/packages/button/src/LionButton.js +++ b/packages/button/src/LionButton.js @@ -92,7 +92,7 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement)) padding: 0; } - :host(:focus) .btn { + :host(:focus:not([disabled])) .btn { /* if you extend, please overwrite */ outline: 2px solid #bde4ff; } @@ -137,6 +137,7 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement)) if (!this.constructor._button) { this.constructor._button = document.createElement('button'); this.constructor._button.setAttribute('tabindex', '-1'); + this.constructor._button.setAttribute('aria-hidden', true); } return this.constructor._button.cloneNode(); }, diff --git a/packages/button/test/lion-button.test.js b/packages/button/test/lion-button.test.js index eae39df63..e6297f22a 100644 --- a/packages/button/test/lion-button.test.js +++ b/packages/button/test/lion-button.test.js @@ -222,6 +222,12 @@ describe('lion-button', () => { ); restoreMockIsIE11(); }); + + it.only('has a native button node with aria-hidden set to true', async () => { + const el = await fixture(''); + + expect(el._nativeButtonNode.getAttribute('aria-hidden')).to.equal('true'); + }); }); describe('form integration', () => {