@@ -147,6 +147,8 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
147147 const flyoutContext = React . useContext ( FlyoutContext ) ;
148148 const [ flyoutXDirection , setFlyoutXDirection ] = React . useState ( flyoutContext . direction ) ;
149149 const ref = React . useRef < HTMLLIElement > ( undefined ) ;
150+ const privateRef = React . useRef ( undefined ) ;
151+ const innerComponentRef = innerRef || privateRef ;
150152 const flyoutVisible = ref === flyoutRef ;
151153
152154 const hasFlyout = flyoutMenu !== undefined ;
@@ -351,7 +353,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
351353 { ...( ! hasCheckbox && { disabled : isDisabled , 'aria-label' : ariaLabel } ) }
352354 { ...( ! hasCheckbox && ! flyoutMenu && { role : isSelectMenu ? 'option' : 'menuitem' } ) }
353355 { ...( ! hasCheckbox && ! flyoutMenu && isSelectMenu && { 'aria-selected' : getIsSelected ( ) } ) }
354- ref = { innerRef }
356+ ref = { innerComponentRef }
355357 { ...( ! hasCheckbox && {
356358 onClick : ( event : React . KeyboardEvent | React . MouseEvent ) => {
357359 if ( ! isAriaDisabled ) {
@@ -433,31 +435,34 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
433435 ) ;
434436
435437 return (
436- < li
437- className = { css (
438- styles . menuListItem ,
439- isDisabled && styles . modifiers . disabled ,
440- isAriaDisabled && styles . modifiers . ariaDisabled ,
441- _isOnPath && styles . modifiers . currentPath ,
442- isLoadButton && styles . modifiers . load ,
443- isLoading && styles . modifiers . loading ,
444- isFocused && 'pf-m-focus' ,
445- isDanger && styles . modifiers . danger ,
446- className
447- ) }
448- onMouseOver = { ( ) => {
449- if ( ! isAriaDisabled ) {
450- onMouseOver ( ) ;
451- }
452- } }
453- { ...( flyoutMenu && ! isAriaDisabled && { onKeyDown : handleFlyout } ) }
454- ref = { ref }
455- role = { ! hasCheckbox ? 'none' : 'menuitem' }
456- { ...( hasCheckbox && { 'aria-label' : ariaLabel } ) }
457- { ...props }
458- >
459- { tooltipProps ? < Tooltip { ...tooltipProps } > { renderItem } </ Tooltip > : renderItem }
460- </ li >
438+ < >
439+ < li
440+ className = { css (
441+ styles . menuListItem ,
442+ isDisabled && styles . modifiers . disabled ,
443+ isAriaDisabled && styles . modifiers . ariaDisabled ,
444+ _isOnPath && styles . modifiers . currentPath ,
445+ isLoadButton && styles . modifiers . load ,
446+ isLoading && styles . modifiers . loading ,
447+ isFocused && 'pf-m-focus' ,
448+ isDanger && styles . modifiers . danger ,
449+ className
450+ ) }
451+ onMouseOver = { ( ) => {
452+ if ( ! isAriaDisabled ) {
453+ onMouseOver ( ) ;
454+ }
455+ } }
456+ { ...( flyoutMenu && ! isAriaDisabled && { onKeyDown : handleFlyout } ) }
457+ ref = { ref }
458+ role = { ! hasCheckbox ? 'none' : 'menuitem' }
459+ { ...( hasCheckbox && { 'aria-label' : ariaLabel } ) }
460+ { ...props }
461+ >
462+ { renderItem }
463+ </ li >
464+ { tooltipProps && < Tooltip { ...tooltipProps } triggerRef = { innerComponentRef as any } /> }
465+ </ >
461466 ) ;
462467} ;
463468
0 commit comments