@@ -8,6 +8,7 @@ import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
8
8
import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils' ;
9
9
import { css , html , LitElement } from 'lit' ;
10
10
import { property , state } from 'lit/decorators.js' ;
11
+ import { ref } from 'lit/directives/ref.js' ;
11
12
import { ifDefined } from 'lit/directives/if-defined.js' ;
12
13
13
14
import { UUIMenuItemEvent } from './UUIMenuItemEvent' ;
@@ -266,6 +267,10 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
266
267
@state ( )
267
268
private iconSlotHasContent = false ;
268
269
270
+ labelButtonChanged ( label ?: Element | undefined ) {
271
+ this . selectableTarget = label || this ;
272
+ }
273
+
269
274
connectedCallback ( ) {
270
275
super . connectedCallback ( ) ;
271
276
if ( ! this . hasAttribute ( 'role' ) ) this . setAttribute ( 'role' , 'menu' ) ;
@@ -305,12 +310,13 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
305
310
306
311
private _renderLabelAsAnchor ( ) {
307
312
if ( this . disabled ) {
308
- return html ` < span id ="label-button ">
313
+ return html ` < span id ="label-button " ${ ref ( this . labelButtonChanged ) } >
309
314
${ this . _renderLabelInside ( ) }
310
315
</ span > ` ;
311
316
}
312
317
return html ` < a
313
318
id ="label-button "
319
+ ${ ref ( this . labelButtonChanged ) }
314
320
href =${ ifDefined ( this . href ) }
315
321
target =${ ifDefined ( this . target || undefined ) }
316
322
rel=${ ifDefined ( this . target === '_blank' ? 'noopener' : undefined ) }
@@ -324,6 +330,7 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
324
330
private _renderLabelAsButton ( ) {
325
331
return html ` < button
326
332
id ="label-button "
333
+ ${ ref ( this . labelButtonChanged ) }
327
334
@click =${ this . onLabelClicked }
328
335
?disabled =${ this . disabled }
329
336
aria-label="${ this . label } ">
0 commit comments