@@ -19,28 +19,25 @@ import { ContextMenuComponent } from "./context-menu.component";
1919@Component ( {
2020 selector : "cds-context-menu-item, ibm-context-menu-item" ,
2121 template : `
22- <div class="cds--context-menu-option__content cds--menu-option__content">
23- <div class="cds--context-menu-option__icon cds--menu-option__icon">
24- <svg *ngIf="selectable && checked" cdsIcon="checkmark" size="16"></svg>
25- <svg *ngIf="!selectable && icon" [cdsIcon]="icon" size="16"></svg>
26- </div>
27- <span class="cds--context-menu-option__label cds--menu-option__label" [title]="label">{{label}}</span>
28- <div class="cds--context-menu-option__info cds--menu-option__info">
29- {{info}}
30- <svg *ngIf="hasChildren" cdsIcon="caret--right" size="16"></svg>
31- </div>
22+ <div class="cds--menu-item__icon">
23+ <svg *ngIf="selectable && checked" cdsIcon="checkmark" size="16"></svg>
24+ <svg *ngIf="!selectable && icon" [cdsIcon]="icon" size="16"></svg>
25+ </div>
26+ <div class="cds--menu-item__label" [title]="label">{{label}}</div>
27+ <div class="cds--menu-item__shortcut">
28+ <ng-container *ngIf="info">{{info}}</ng-container>
29+ <svg *ngIf="hasChildren" cdsIcon="caret--right" size="16"></svg>
3230 </div>
3331 <ng-content></ng-content>
3432 ` ,
3533 styles : [ `
3634 :host {
37- display: list-item;
38- list-style: none;
35+ grid-template-columns: 1rem 1fr max-content;
3936 }
4037 ` ]
4138} )
4239export class ContextMenuItemComponent implements OnInit , AfterContentInit , OnDestroy {
43- @HostBinding ( "class.cds--menu-option " ) optionClass = true ;
40+ @HostBinding ( "class.cds--menu-item " ) optionClass = true ;
4441 @HostBinding ( "attr.role" ) role = "menuitem" ;
4542 @HostBinding ( "attr.tabindex" ) tabindex = - 1 ;
4643 @HostBinding ( "attr.aria-haspopup" ) ariaHasPopup = null ;
@@ -106,7 +103,6 @@ export class ContextMenuItemComponent implements OnInit, AfterContentInit, OnDes
106103 this . hasChildren = true ;
107104 this . ariaHasPopup = true ;
108105 this . ariaExpanded = false ;
109- this . childContextMenu . root = false ;
110106 }
111107 }
112108
@@ -144,7 +140,7 @@ export class ContextMenuItemComponent implements OnInit, AfterContentInit, OnDes
144140 if ( this . childContextMenu ) {
145141 this . childContextMenu . open = true ;
146142 this . ariaExpanded = true ;
147- const dimensions = this . getDimensions ( ) ;
143+ const dimensions = this . elementRef . nativeElement . getBoundingClientRect ( ) ;
148144 this . childContextMenu . position . left = dimensions . left + dimensions . width ;
149145 // subtract 4px to account for margins
150146 this . childContextMenu . position . top = dimensions . top - 4 ;
@@ -185,12 +181,6 @@ export class ContextMenuItemComponent implements OnInit, AfterContentInit, OnDes
185181 this . elementRef . nativeElement . focus ( ) ;
186182 }
187183
188- getDimensions ( ) {
189- const element : HTMLElement = this . elementRef . nativeElement
190- . querySelector ( ".cds--context-menu-option__content, .cds--menu-option__content" ) ;
191- return element . getBoundingClientRect ( ) ;
192- }
193-
194184 ngOnDestroy ( ) {
195185 this . subscriptions . unsubscribe ( ) ;
196186 }
0 commit comments