@@ -33,7 +33,7 @@ export default defineComponent({
33
33
inheritAttrs : false ,
34
34
props : menuItemProps ,
35
35
emits : [ 'mouseenter' , 'mouseleave' , 'click' , 'keydown' , 'focus' ] ,
36
- slots : [ 'icon' ] ,
36
+ slots : [ 'icon' , 'title' ] ,
37
37
setup ( props , { slots, emit, attrs } ) {
38
38
const instance = getCurrentInstance ( ) ;
39
39
const key = instance . vnode . key ;
@@ -149,6 +149,7 @@ export default defineComponent({
149
149
} ;
150
150
151
151
const renderItemChildren = ( icon : any , children : any ) => {
152
+ const wrapNode = < span class = { `${ prefixCls . value } -title-content` } > { children } </ span > ;
152
153
// inline-collapsed.md demo 依赖 span 来隐藏文字,有 icon 属性,则内部包裹一个 span
153
154
// ref: https://github.com/ant-design/ant-design/pull/23456
154
155
if ( ! icon || ( isValidElement ( children ) && children . type === 'span' ) ) {
@@ -157,16 +158,15 @@ export default defineComponent({
157
158
< div class = { `${ prefixCls . value } -inline-collapsed-noicon` } > { children . charAt ( 0 ) } </ div >
158
159
) ;
159
160
}
160
- return children ;
161
161
}
162
- return < span class = { ` ${ prefixCls . value } -title-content` } > { children } </ span > ;
162
+ return wrapNode ;
163
163
} ;
164
164
165
165
// ========================== DirectionStyle ==========================
166
166
const directionStyle = useDirectionStyle ( computed ( ( ) => keysPath . value . length ) ) ;
167
167
168
168
return ( ) => {
169
- const { title } = props ;
169
+ const title = props . title ?? slots . title ?. ( ) ;
170
170
const children = flattenChildren ( slots . default ?.( ) ) ;
171
171
const childrenLength = children . length ;
172
172
let tooltipTitle : any = title ;
0 commit comments