From e00d06e45bf0b15c018c3313fb129d938f56cb2b Mon Sep 17 00:00:00 2001 From: Jan Bensch <53659806+janbensch@users.noreply.github.com> Date: Tue, 14 Mar 2023 05:50:08 +0100 Subject: [PATCH] Fix wrong generation of `aria-labelledby` in tab navigation (#38223) * fix wrong generation of aria-labelledby in tab navigation * fix wrong test --------- Co-authored-by: Jan Bensch Co-authored-by: XhmikosR --- js/src/tab.js | 2 +- js/tests/unit/tab.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/tab.js b/js/src/tab.js index cdba0e2e6..137cc0123 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -212,7 +212,7 @@ class Tab extends BaseComponent { this._setAttributeIfNotExists(target, 'role', 'tabpanel') if (child.id) { - this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`) + this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`) } } diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js index 1ac5929e1..95b31b4f0 100644 --- a/js/tests/unit/tab.spec.js +++ b/js/tests/unit/tab.spec.js @@ -514,7 +514,7 @@ describe('Tab', () => { expect(tabPanel.hasAttribute('tabindex')).toBeFalse() expect(tabPanel.hasAttribute('tabindex2')).toBeFalse() - expect(tabPanel.getAttribute('aria-labelledby')).toEqual('#foo') + expect(tabPanel.getAttribute('aria-labelledby')).toEqual('foo') expect(tabPanel2.hasAttribute('aria-labelledby')).toBeFalse() }) })