From a1d6dd90a8bd7259c82174206d1fb452fc1058b9 Mon Sep 17 00:00:00 2001 From: Oleksii Kadurin Date: Wed, 22 Jan 2025 12:16:56 +0100 Subject: [PATCH] Set aria-disabled to true or delete it (#2452) fix: remove aria-disabled attribute --- .changeset/hip-nails-matter.md | 5 +++++ packages/ui/components/button/src/LionButton.js | 6 +++++- .../ui/components/button/test-suites/LionButton.suite.js | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/hip-nails-matter.md diff --git a/.changeset/hip-nails-matter.md b/.changeset/hip-nails-matter.md new file mode 100644 index 0000000000..cde8a7e818 --- /dev/null +++ b/.changeset/hip-nails-matter.md @@ -0,0 +1,5 @@ +--- +'@lion/ui': patch +--- + +[button] set the 'aria-disabled' attribute to 'true' when disabled and remove it when not disabled diff --git a/packages/ui/components/button/src/LionButton.js b/packages/ui/components/button/src/LionButton.js index f5d28895ce..191a56805a 100644 --- a/packages/ui/components/button/src/LionButton.js +++ b/packages/ui/components/button/src/LionButton.js @@ -149,7 +149,11 @@ export class LionButton extends DisabledWithTabIndexMixin(LitElement) { super.updated(changedProperties); if (changedProperties.has('disabled')) { - this.setAttribute('aria-disabled', `${this.disabled}`); // create mixin if we need it in more places + if (this.disabled) { + this.setAttribute('aria-disabled', 'true'); + } else if (this.getAttribute('aria-disabled') !== null) { + this.removeAttribute('aria-disabled'); + } } } diff --git a/packages/ui/components/button/test-suites/LionButton.suite.js b/packages/ui/components/button/test-suites/LionButton.suite.js index 48e551c821..1835bf4387 100644 --- a/packages/ui/components/button/test-suites/LionButton.suite.js +++ b/packages/ui/components/button/test-suites/LionButton.suite.js @@ -40,7 +40,7 @@ export function LionButtonSuite({ klass = LionButton } = {}) { el.disabled = false; await el.updateComplete; expect(el.getAttribute('tabindex')).to.equal('0'); - expect(el.getAttribute('aria-disabled')).to.equal('false'); + expect(el.getAttribute('aria-disabled')).to.not.exist; expect(el.hasAttribute('disabled')).to.equal(false); el.disabled = true;