From a6babe0400f7c361b383f1f83d69d5cf0f7438d0 Mon Sep 17 00:00:00 2001 From: CaptM44 Date: Thu, 19 Jan 2023 12:40:01 -0500 Subject: [PATCH] fixed issue where focustrap was skipping over anchor tags when tabbing --- src/app/components/dom/domhandler.spec.ts | 7 +++++-- src/app/components/dom/domhandler.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/components/dom/domhandler.spec.ts b/src/app/components/dom/domhandler.spec.ts index b987a89533f..d21015d28d9 100755 --- a/src/app/components/dom/domhandler.spec.ts +++ b/src/app/components/dom/domhandler.spec.ts @@ -66,12 +66,15 @@ describe('DomHandler', () => { const element = document.createElement('div'); const childEl = document.createElement('p'); const childEl2 = document.createElement('a'); - const childEl3 = document.createElement('button'); + const childEl3 = document.createElement('a'); + const childEl4 = document.createElement('button'); + childEl2.setAttribute('href', 'https://www.primefaces.org/primeng/'); element.appendChild(childEl); element.appendChild(childEl2); element.appendChild(childEl3); + element.appendChild(childEl4); document.body.appendChild(element); - expect(DomHandler.getFocusableElements(element).length).toEqual(1); + expect(DomHandler.getFocusableElements(element).length).toEqual(2); }); it('should get the next focusable element', () => { diff --git a/src/app/components/dom/domhandler.ts b/src/app/components/dom/domhandler.ts index 3b22b53f1f2..989cce7eda8 100755 --- a/src/app/components/dom/domhandler.ts +++ b/src/app/components/dom/domhandler.ts @@ -607,7 +607,7 @@ export class DomHandler { let focusableElements = DomHandler.find( element, `button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), - [href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), + [href]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), [tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), [contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]):not(.p-disabled)`