Skip to content

Commit

Permalink
Merge pull request #12530 from mmorgan4x/focus-trap-anchor-fix
Browse files Browse the repository at this point in the history
fixed: issue where focustrap was skipping over anchor tags when tabbing #12527
  • Loading branch information
cetincakiroglu authored Jan 26, 2023
2 parents b6cfb8c + a6babe0 commit addafba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/app/components/dom/domhandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/dom/domhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down

0 comments on commit addafba

Please sign in to comment.