diff --git a/src/components/dropdown/bl-dropdown.stories.mdx b/src/components/dropdown/bl-dropdown.stories.mdx
index f6893da0..061b3b53 100644
--- a/src/components/dropdown/bl-dropdown.stories.mdx
+++ b/src/components/dropdown/bl-dropdown.stories.mdx
@@ -1,8 +1,8 @@
+import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
+import { userEvent } from '@storybook/testing-library';
import { html } from 'lit';
import { ifDefined } from 'lit/directives/if-defined.js';
import { styleMap } from 'lit/directives/style-map.js';
-import { Meta, Canvas, ArgsTable, Story } from '@storybook/addon-docs';
-import { userEvent } from '@storybook/testing-library';
{
const dropdown = canvasElement?.querySelector('bl-dropdown')
- if(dropdown.shadowRoot) {
- const button = dropdown.shadowRoot.querySelector('bl-button')
+ if (dropdown.shadowRoot) {
+ const button = dropdown.shadowRoot.querySelector("bl-button")?.shadowRoot?.querySelector("button");
await userEvent.click(button);
}
}
@@ -78,6 +78,22 @@ export const IconDropdownTemplate = (args) => html`Action 5
`
+export const DisabledItemDropdownTemplate = (args) => html`
+ ${args.content || 'Action 1'}
+ Action 2
+
+ Action 3
+ Action 4
+ Action 5
+ `
+
export const Template = (args) => html`
${SingleDropdownButtonTemplate({...args})}
${SingleDropdownButtonTemplate({variant: 'secondary', ...args})}
@@ -148,7 +164,7 @@ If dropdown button has an action with a long text that can not fit in a single l
You can add icons to your dropdown buttons using the `icon` attribute. The icon will be displayed on the left side of the button label.
+## Disabled
+You can disable the item by setting the `disabled` attribute.
+
+
+ {Template.bind({})}
+
+
+
diff --git a/src/components/dropdown/item/bl-dropdown-item.test.ts b/src/components/dropdown/item/bl-dropdown-item.test.ts
index 582a0a20..980e4af7 100644
--- a/src/components/dropdown/item/bl-dropdown-item.test.ts
+++ b/src/components/dropdown/item/bl-dropdown-item.test.ts
@@ -1,5 +1,5 @@
+import { assert, expect, fixture, html, oneEvent } from "@open-wc/testing";
import BlDropdownItem from "./bl-dropdown-item";
-import { assert, fixture, html, oneEvent, expect } from "@open-wc/testing";
import type typeOfBlDropdownItem from "./bl-dropdown-item";
@@ -55,7 +55,12 @@ describe("bl-dropdown-item", () => {
);
const button = el.shadowRoot?.querySelector("bl-button");
- setTimeout(() => button?.click());
+ setTimeout(() => button?.dispatchEvent(
+ new CustomEvent("bl-click", {
+ bubbles: true,
+ composed: true,
+ })
+ ));
const event = await oneEvent(el, "bl-dropdown-item-click");
expect(el).to.exist;
diff --git a/src/components/dropdown/item/bl-dropdown-item.ts b/src/components/dropdown/item/bl-dropdown-item.ts
index 87e4fb29..c46a3545 100644
--- a/src/components/dropdown/item/bl-dropdown-item.ts
+++ b/src/components/dropdown/item/bl-dropdown-item.ts
@@ -1,4 +1,4 @@
-import { LitElement, html, CSSResultGroup, TemplateResult } from "lit";
+import { CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { event, EventDispatcher } from "../../../utilities/event";
@@ -32,6 +32,12 @@ export default class BlDropdownItem extends LitElement {
@property({ type: String })
icon?: BaklavaIcon;
+ /**
+ * Sets item as disabled
+ */
+ @property({ type: Boolean, reflect: true })
+ disabled = false;
+
@event("bl-dropdown-item-click") private onClick: EventDispatcher;
private _handleClick() {
@@ -78,7 +84,8 @@ export default class BlDropdownItem extends LitElement {
kind="neutral"
icon="${ifDefined(this.icon)}"
role="menuitem"
- @click="${this._handleClick}"
+ ?disabled="${this.disabled}"
+ @bl-click="${this._handleClick}"
>
`;
}
diff --git a/src/components/split-button/bl-split-button.test.ts b/src/components/split-button/bl-split-button.test.ts
index 97c2ae44..f797a95f 100644
--- a/src/components/split-button/bl-split-button.test.ts
+++ b/src/components/split-button/bl-split-button.test.ts
@@ -1,18 +1,18 @@
-import BlSplitButton from "./bl-split-button";
import {
- assert,
- fixture,
- html,
- oneEvent,
- expect,
- elementUpdated,
- waitUntil,
- } from "@open-wc/testing";
-import type typeOfBlSplitButton from "./bl-split-button";
+ assert,
+ elementUpdated,
+ expect,
+ fixture,
+ html,
+ oneEvent,
+ waitUntil,
+} from "@open-wc/testing";
import { sendKeys } from "@web/test-runner-commands";
-import BlPopover from "../popover/bl-popover";
import BlButton from "../button/bl-button";
import "../popover/bl-popover";
+import BlPopover from "../popover/bl-popover";
+import type typeOfBlSplitButton from "./bl-split-button";
+import BlSplitButton from "./bl-split-button";
describe("bl-split-button", () => {
it("is defined", () => {
@@ -143,7 +143,12 @@ describe("bl-split-button", () => {
.querySelector("bl-dropdown-item")
?.shadowRoot?.querySelector("bl-button") as HTMLElement | null;
- item?.click();
+ item?.dispatchEvent(
+ new CustomEvent("bl-click", {
+ bubbles: true,
+ composed: true,
+ })
+ );
setTimeout(() => {
expect(el.opened).to.false;