Skip to content

Commit 05b0dce

Browse files
authored
fix: menu dropdown should not be shown if no items in the list (#967)
* fix: menu dropdown should not be shown if no items in the list
1 parent 820b1cb commit 05b0dce

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

projects/components/src/menu-dropdown/menu-dropdown.component.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ describe('Menu dropdown Component', () => {
2626

2727
test('should display trigger content as expected', () => {
2828
spectator = createHost(
29-
`
30-
<ht-menu-dropdown label="Settings" icon="${IconType.MoreHorizontal}">
31-
</ht-menu-dropdown>`
29+
`<ht-menu-dropdown label="Settings" icon="${IconType.MoreHorizontal}"><ht-menu-item label="Option 1"></ht-menu-item></ht-menu-dropdown>`
3230
);
3331

3432
expect(spectator.query('.trigger-content')).toExist();
@@ -78,4 +76,10 @@ describe('Menu dropdown Component', () => {
7876

7977
expect(onClickSpy).not.toHaveBeenCalled();
8078
});
79+
80+
test('should not show the dropdown if no items to show.', () => {
81+
spectator = createHost(`<ht-menu-dropdown label="Settings" icon="${IconType.MoreHorizontal}"></ht-menu-dropdown>`);
82+
83+
expect(spectator.query('ht-popover-trigger')).not.toExist();
84+
});
8185
});

projects/components/src/menu-dropdown/menu-dropdown.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { MenuItemComponent } from './menu-item/menu-item.component';
99
changeDetection: ChangeDetectionStrategy.OnPush,
1010
template: `
1111
<ht-event-blocker event="click" [enabled]="true">
12-
<ht-popover [closeOnClick]="true" [disabled]="this.disabled">
12+
<ht-popover [closeOnClick]="true" [disabled]="this.disabled" *ngIf="this.items?.length > 0">
1313
<ht-popover-trigger>
1414
<div class="trigger-content" [ngClass]="{ disabled: this.disabled, labeled: !!this.label }">
1515
<ht-label *ngIf="this.label" class="trigger-label" [label]="this.label"> </ht-label>

0 commit comments

Comments
 (0)