Skip to content

Commit f36757a

Browse files
committed
fix: styles of context menu item content
when no icons or only select icons are used the item name was diplayed with 1rem icon width
1 parent 46cb2e6 commit f36757a

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/context-menu/context-menu-item.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ import { ItemClickEvent } from "./context-menu.types";
3333
`,
3434
styles: [`
3535
:host {
36-
grid-template-columns: 1rem 1fr max-content;
36+
grid-template-columns: 1fr max-content;
37+
38+
&[icon], &[type="checkbox"], &[type="radio"] {
39+
grid-template-columns: 1rem 1fr max-content;
40+
}
3741
}
3842
`]
3943
})

src/context-menu/context-menu.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ export class ContextMenuComponent implements OnChanges, AfterViewInit {
4747
@HostBinding("attr.tabindex") tabindex = "-1";
4848
@HostBinding("style.left.px") get leftPosition() { return this.position.left; }
4949
@HostBinding("style.top.px") get topPosition() { return this.position.top; }
50-
51-
/**
52-
* @todo - convert to getter in v6, should resolve expression has changed
53-
* after switching to on OnPush Change Detection Strategy
54-
*/
5550
@HostBinding("class.cds--menu--with-icons") iconClass = false;
5651

5752
constructor(protected elementRef: ElementRef) { }
@@ -66,8 +61,8 @@ export class ContextMenuComponent implements OnChanges, AfterViewInit {
6661
setTimeout(() => {
6762
const nativeElement = this.elementRef.nativeElement;
6863
if (nativeElement) {
69-
this.iconClass = !!nativeElement
70-
.querySelector(".cds--menu-item .cds--menu-item__icon svg");
64+
this.iconClass = !!this.elementRef.nativeElement
65+
.querySelectorAll(".cds--menu-item[icon], .cds--menu-item[type='checkbox'], .cds--menu-item[type='radio']").length;
7166
}
7267
});
7368
}

0 commit comments

Comments
 (0)