File tree Expand file tree Collapse file tree
web-components/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,6 +190,12 @@ export const MenuItem = forwardRef<HTMLLIElement, MenuItemProps>(
190190 const keyboardClickEvent = ( e : KeyboardEvent ) =>
191191 match ( e , keys . Enter ) || match ( e , keys . Space ) ;
192192
193+ function handleMouseDown ( e : MouseEvent < HTMLLIElement > ) {
194+ if ( isDisabled ) {
195+ e . preventDefault ( ) ;
196+ }
197+ }
198+
193199 function handleKeyDown ( e : KeyboardEvent < HTMLLIElement > ) {
194200 if ( hasChildren && match ( e , keys . ArrowRight ) ) {
195201 openSubmenu ( ) ;
@@ -268,6 +274,7 @@ export const MenuItem = forwardRef<HTMLLIElement, MenuItemProps>(
268274 aria-disabled = { isDisabled ?? undefined }
269275 aria-haspopup = { hasChildren ?? undefined }
270276 aria-expanded = { hasChildren ? submenuOpen : undefined }
277+ onMouseDown = { handleMouseDown }
271278 onClick = { handleClick }
272279 onKeyDown = { handleKeyDown }
273280 onKeyUp = { handleKeyUp }
Original file line number Diff line number Diff line change @@ -95,15 +95,14 @@ class CDSMenuButton extends HostListenerMixin(LitElement) {
9595 return ;
9696 }
9797
98+ // Handle clicks on trigger only, other listeners handle clicks on menu items
9899 const path = event . composedPath ( ) ;
99100 if ( path . includes ( trigger ) ) {
100101 if ( this . _open ) {
101102 this . _closeMenu ( { restoreFocus : true } ) ;
102103 } else {
103104 this . _open = true ;
104105 }
105- } else if ( this . _open ) {
106- this . _closeMenu ( ) ;
107106 }
108107 } ;
109108
Original file line number Diff line number Diff line change @@ -71,11 +71,15 @@ $css--plex: true !default;
7171 display : var (--child-icon-property , none );
7272}
7373
74- :host ([aria-disabled = ' true' ]) * {
74+ :host ([aria-disabled = ' true' ]) {
7575 color : $text-disabled ;
7676 cursor : not-allowed ;
7777}
7878
79+ :host ([aria-disabled = ' true' ]) :where(* ) {
80+ color : inherit ;
81+ }
82+
7983:host ([aria-disabled = ' true' ]:hover ),
8084:host ([aria-disabled = ' true' ].#{$prefix } --menu-item--danger :hover ) {
8185 background-color : $layer ;
Original file line number Diff line number Diff line change @@ -188,6 +188,13 @@ class CDSmenuItem extends HostListenerMixin(HostListenerMixin(LitElement)) {
188188 this . _handleClick ( event ) ;
189189 }
190190
191+ @HostListener ( 'mousedown' )
192+ handleMouseDown ( event : MouseEvent ) {
193+ if ( this . disabled ) {
194+ event . preventDefault ( ) ;
195+ }
196+ }
197+
191198 @HostListener ( 'mouseenter' )
192199 handleMouseEnter ( ) {
193200 if ( this . hasSubmenu ) {
@@ -263,6 +270,10 @@ class CDSmenuItem extends HostListenerMixin(HostListenerMixin(LitElement)) {
263270 }
264271
265272 _handleClick = ( e : MouseEvent | KeyboardEvent ) : void => {
273+ if ( this . disabled ) {
274+ return ;
275+ }
276+
266277 if ( this . hasSubmenu ) {
267278 this . _openSubmenu ( ) ;
268279 return ;
You can’t perform that action at this time.
0 commit comments