Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(split-button): fix event bubbling for buttons inside split button #879

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/split-button/bl-split-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { event, EventDispatcher } from "../../utilities/event";
import "../button/bl-button";
import { TargetType } from "../button/bl-button";
import { ButtonSize, ButtonVariant, ButtonKind } from "../button/bl-button";
import BlButton from "../button/bl-button";
import BlDropdownItem, { blDropdownItemTag } from "../dropdown/item/bl-dropdown-item";
import { BaklavaIcon } from "../icon/icon-list";
import BlPopover from "../popover/bl-popover";
Expand All @@ -29,6 +30,12 @@ export default class BlSplitButton extends LitElement {
@query("bl-popover")
private _popover: BlPopover;

@query("#split-main-button")
private mainButton: BlButton;

@query("#dropdown-button")
private dropdownButton: BlButton;

@state() private _isPopoverOpen = false;

/**
Expand Down Expand Up @@ -145,6 +152,8 @@ export default class BlSplitButton extends LitElement {
firstUpdated() {
// To ensure proper rendering, we set `_popover.target` after the template has been created.
this._popover.target = this.trigger;
this.dropdownButton.addEventListener("bl-click", e => e.stopPropagation());
this.mainButton.addEventListener("bl-click", e => e.stopPropagation());
}

get opened() {
Expand Down
Loading