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(core/dropdown-item): dropdown item disabled state events & icon color #390

Merged
merged 7 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/core/scss/components/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
> .glyph {
color: var(--theme-menu-item-icon--color);

&.disabled {
color: var(--color-weak-text);
}

&.glyph-single-check {
color: var(--theme-menu-item-icon-check--color);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/components/dropdown-item/dropdown-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
.label {
@include ellipsis;
}

&.disabled {
pointer-events: none;
}
}

::slotted(ix-icon) {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/dropdown-item/dropdown-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class DropdownItem {
checked: this.checked,
'icon-text': this.label !== undefined && this.icon !== undefined,
'icon-only': this.label === undefined && this.icon !== undefined,
disabled: this.disabled,
}}
>
<button
Expand All @@ -90,6 +91,7 @@ export class DropdownItem {
class={{
glyph: true,
[`glyph-${this.icon}`]: true,
disabled: this.disabled,
}}
></span>
) : null}
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/components/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,13 @@ export class Dropdown {
this.close();
}
break;

case 'inside':
if (this.dropdownRef.contains(target)) {
if (this.dropdownRef.contains(target) && this.hostElement !== target) {
this.close();
}
break;
case 'both':
if (this.hostElement !== target) this.close();

default:
this.close();
Expand Down
30 changes: 30 additions & 0 deletions packages/core/src/tests/dropdown/disabled/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
SPDX-FileCopyrightText: 2022 Siemens AG

SPDX-License-Identifier: MIT
-->

<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
</head>
<body style="width: 100vw; height: 100vh">
<ix-button id="trigger">Open</ix-button>
<ix-dropdown trigger="trigger">
<ix-dropdown-item
id="test"
label="Item 1"
icon="print"
disabled
></ix-dropdown-item>
<ix-dropdown-item label="Item 2"></ix-dropdown-item>
<ix-dropdown-item>Custom</ix-dropdown-item>
</ix-dropdown>
<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions packages/core/src/tests/dropdown/dropdown.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ regressionTest.describe('dropdown', () => {
});
});

regressionTest('disabled', async ({ page }) => {
await page.goto('dropdown/disabled');

await page.locator('ix-button').click();
await page.waitForSelector('.dropdown-menu.show');

expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
maxDiffPixelRatio: 0.05,
});
});

regressionTest('handle multiple', async ({ page }) => {
await page.goto('dropdown/multiple');

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.