@@ -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' ;
@@ -261,6 +262,10 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
261
262
@state ( )
262
263
private iconSlotHasContent = false ;
263
264
265
+ labelButtonChanged ( label ?: Element | undefined ) {
266
+ this . selectableTarget = label || this ;
267
+ }
268
+
264
269
connectedCallback ( ) {
265
270
super . connectedCallback ( ) ;
266
271
if ( ! this . hasAttribute ( 'role' ) ) this . setAttribute ( 'role' , 'menu' ) ;
@@ -300,12 +305,13 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
300
305
301
306
private _renderLabelAsAnchor ( ) {
302
307
if ( this . disabled ) {
303
- return html ` < span id ="label-button ">
308
+ return html ` < span id ="label-button " ${ ref ( this . labelButtonChanged ) } >
304
309
${ this . _renderLabelInside ( ) }
305
310
</ span > ` ;
306
311
}
307
312
return html ` < a
308
313
id ="label-button "
314
+ ${ ref ( this . labelButtonChanged ) }
309
315
href =${ ifDefined ( this . href ) }
310
316
target =${ ifDefined ( this . target || undefined ) }
311
317
rel=${ ifDefined ( this . target === '_blank' ? 'noopener' : undefined ) }
@@ -319,6 +325,7 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
319
325
private _renderLabelAsButton ( ) {
320
326
return html ` < button
321
327
id ="label-button "
328
+ ${ ref ( this . labelButtonChanged ) }
322
329
@click =${ this . onLabelClicked }
323
330
?disabled =${ this . disabled }
324
331
aria-label="${ this . label } ">
0 commit comments