Skip to content

Commit

Permalink
Fix bug in toolbar click handler when a slotted element has child ele…
Browse files Browse the repository at this point in the history
…ments (microsoft#6830)

* Fix bug with nested elements in toolbar click handler

* Change files

* lint

* update change description

* slight test improvement

* Update change/@microsoft-fast-foundation-2ada25c3-3fb4-48ba-893d-e64d11f7f095.json

---------

Co-authored-by: Chris Holt <[email protected]>
  • Loading branch information
mollykreis and chrisdholt committed Oct 12, 2023
1 parent 21f8185 commit 7c65d30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix bug in toolbar click handler when a slotted element has child elements",
"packageName": "@microsoft/fast-foundation",
"email": "[email protected]",
"dependentChangeType": "prerelease"
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ export class Toolbar extends FoundationElement {
* @internal
*/
public clickHandler(e: MouseEvent): boolean | void {
const activeIndex = this.focusableElements?.indexOf(e.target as HTMLElement);
const activeIndex = this.focusableElements?.findIndex(x =>
x.contains(e.target as HTMLElement)
);
if (activeIndex > -1 && this.activeIndex !== activeIndex) {
this.setFocusedElement(activeIndex);
}
Expand Down

0 comments on commit 7c65d30

Please sign in to comment.