1- import { flattenChildren , getPropsSlot , isValidElement } from '../../_util/props-util' ;
1+ import { flattenChildren , isValidElement } from '../../_util/props-util' ;
22import PropTypes from '../../_util/vue-types' ;
33import type { ExtractPropTypes , PropType } from 'vue' ;
44import {
@@ -13,12 +13,13 @@ import { useInjectKeyPath, useMeasure } from './hooks/useKeyPath';
1313import { useInjectFirstLevel , useInjectMenu } from './hooks/useMenuContext' ;
1414import { cloneElement } from '../../_util/vnode' ;
1515import Tooltip from '../../tooltip' ;
16- import type { MenuInfo } from './interface' ;
16+ import type { ItemType , MenuInfo } from './interface' ;
1717import KeyCode from '../../_util/KeyCode' ;
1818import useDirectionStyle from './hooks/useDirectionStyle' ;
1919import Overflow from '../../vc-overflow' ;
2020import devWarning from '../../vc-util/devWarning' ;
2121import type { MouseEventHandler } from '../../_util/EventInterface' ;
22+ import { objectType } from '../../_util/type' ;
2223
2324let indexGuid = 0 ;
2425export const menuItemProps = ( ) => ( {
@@ -33,6 +34,8 @@ export const menuItemProps = () => ({
3334 onClick : Function as PropType < MouseEventHandler > ,
3435 onKeydown : Function as PropType < MouseEventHandler > ,
3536 onFocus : Function as PropType < MouseEventHandler > ,
37+ // Internal user prop
38+ originItemValue : objectType < ItemType > ( ) ,
3639} ) ;
3740
3841export type MenuItemProps = Partial < ExtractPropTypes < ReturnType < typeof menuItemProps > > > ;
@@ -215,7 +218,7 @@ export default defineComponent({
215218 optionRoleProps [ 'aria-selected' ] = selected . value ;
216219 }
217220
218- const icon = getPropsSlot ( slots , props , ' icon' ) ;
221+ const icon = props . icon ?? slots . icon ?. ( props ) ;
219222 return (
220223 < Tooltip
221224 { ...tooltipProps }
@@ -248,7 +251,7 @@ export default defineComponent({
248251 title = { typeof title === 'string' ? title : undefined }
249252 >
250253 { cloneElement (
251- typeof icon === 'function' ? icon ( ) : icon ,
254+ typeof icon === 'function' ? icon ( props . originItemValue ) : icon ,
252255 {
253256 class : `${ prefixCls . value } -item-icon` ,
254257 } ,
0 commit comments