Skip to content

Commit

Permalink
fix focus on context enter when target has tabindex equal to -1
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed Apr 18, 2023
1 parent 983ccd2 commit aa3fd32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-eagles-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chialab/loock": patch
---

Fix focus on context enter when target has tabindex equal to -1.
7 changes: 2 additions & 5 deletions src/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,8 @@ export class Context {
console.warn('created a Context without aria-label', this);
}
await dispatchAsyncEvent(element, 'focusenter', this);
if (target !== this.element) {
const children = this.findFocusableChildren();
if (children.indexOf(target) !== -1) {
this.setCurrentElement(target, false);
}
if (element.contains(target)) {
this.setCurrentElement(target, false);
}
this.restore();
}
Expand Down

0 comments on commit aa3fd32

Please sign in to comment.