@@ -140,6 +140,14 @@ export class LyraContextMenu extends LyraElement {
140140 this . contributions = [ ...wildcard , ...categoryMatches , ...specific ] ;
141141 }
142142
143+ /** Returns true when registry contributions or part-supplied menu content exist. */
144+ private hasMenuBody ( ) : boolean {
145+ this . refreshContributions ( ) ;
146+ if ( this . contributions . length > 0 ) return true ;
147+ const partContent = this . partContextMenuRenderer ? this . partContextMenuRenderer ( ) : nothing ;
148+ return partContent !== nothing ;
149+ }
150+
143151 /**
144152 * Gets the element at the given point, traversing shadow DOM boundaries recursively.
145153 * This is necessary because elementFromPoint() doesn't penetrate shadow roots.
@@ -187,7 +195,9 @@ export class LyraContextMenu extends LyraElement {
187195 }
188196 }
189197
190- public show ( position : { x : number , y : number } , mouseEvent ?: MouseEvent ) {
198+ /** Opens the menu at `position`. Returns false when there is nothing to show (no thin empty panel). */
199+ public show ( position : { x : number , y : number } , mouseEvent ?: MouseEvent ) : boolean {
200+ if ( ! this . hasMenuBody ( ) ) return false ;
191201 if ( mouseEvent ) {
192202 this . triggerClickUnderCursor ( mouseEvent ) ;
193203 }
@@ -196,6 +206,7 @@ export class LyraContextMenu extends LyraElement {
196206 this . updateComplete . then ( ( ) => {
197207 document . addEventListener ( 'pointerdown' , this . boundHandleDocumentPointerDown , { capture : true } ) ;
198208 } ) ;
209+ return true ;
199210 }
200211
201212 private onClose ( ) {
0 commit comments