diff --git a/change/@microsoft-fast-foundation-2ada25c3-3fb4-48ba-893d-e64d11f7f095.json b/change/@microsoft-fast-foundation-2ada25c3-3fb4-48ba-893d-e64d11f7f095.json new file mode 100644 index 00000000000..b88d36dc993 --- /dev/null +++ b/change/@microsoft-fast-foundation-2ada25c3-3fb4-48ba-893d-e64d11f7f095.json @@ -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": "20542556+mollykreis@users.noreply.github.com", + "dependentChangeType": "prerelease" +} diff --git a/packages/web-components/fast-foundation/src/toolbar/toolbar.ts b/packages/web-components/fast-foundation/src/toolbar/toolbar.ts index 967ce7ac78f..a7182852662 100644 --- a/packages/web-components/fast-foundation/src/toolbar/toolbar.ts +++ b/packages/web-components/fast-foundation/src/toolbar/toolbar.ts @@ -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); }