@@ -41,6 +41,8 @@ import type { FocusEventHandler, MouseEventHandler } from '../../_util/EventInte
4141import collapseMotion from '../../_util/collapseMotion' ;
4242import type { ItemType } from './hooks/useItems' ;
4343import useItems from './hooks/useItems' ;
44+ import useStyle from '../style' ;
45+ import { useInjectOverride } from './OverrideContext' ;
4446
4547export const menuProps = ( ) => ( {
4648 id : String ,
@@ -95,7 +97,17 @@ export default defineComponent({
9597 props : menuProps ( ) ,
9698 slots : [ 'expandIcon' , 'overflowedIndicator' ] ,
9799 setup ( props , { slots, emit, attrs } ) {
98- const { prefixCls, direction, getPrefixCls } = useConfigInject ( 'menu' , props ) ;
100+ const { direction, getPrefixCls } = useConfigInject ( 'menu' , props ) ;
101+ const override = useInjectOverride ( ) ;
102+ const prefixCls = computed ( ( ) => {
103+ return getPrefixCls ( 'menu' , props . prefixCls || override ?. prefixCls ?. value ) ;
104+ } ) ;
105+ const [ wrapSSR , hashId ] = useStyle (
106+ prefixCls ,
107+ computed ( ( ) => {
108+ return ! override ;
109+ } ) ,
110+ ) ;
99111 const store = shallowRef < Map < string , StoreMenuInfo > > ( new Map ( ) ) ;
100112 const siderCollapsed = inject ( SiderCollapsedKey , ref ( undefined ) ) ;
101113 const inlineCollapsed = computed ( ( ) => {
@@ -265,6 +277,9 @@ export default defineComponent({
265277 mergedMode . value = props . mode ;
266278 mergedInlineCollapsed . value = false ;
267279 }
280+ if ( override ?. mode ?. value ) {
281+ mergedMode . value = override . mode . value ;
282+ }
268283 } ) ;
269284
270285 const isInlineMode = computed ( ( ) => mergedMode . value === 'inline' ) ;
@@ -346,6 +361,7 @@ export default defineComponent({
346361 const onInternalClick = ( info : MenuInfo ) => {
347362 emit ( 'click' , info ) ;
348363 triggerSelection ( info ) ;
364+ override ?. onClick ?.( ) ;
349365 } ;
350366
351367 const onInternalOpenChange = ( key : Key , open : boolean ) => {
@@ -406,7 +422,7 @@ export default defineComponent({
406422 triggerSubMenuAction : computed ( ( ) => props . triggerSubMenuAction ) ,
407423 getPopupContainer : computed ( ( ) => props . getPopupContainer ) ,
408424 inlineCollapsed : mergedInlineCollapsed ,
409- antdMenuTheme : computed ( ( ) => props . theme ) ,
425+ theme : computed ( ( ) => props . theme ) ,
410426 siderCollapsed,
411427 defaultMotions : computed ( ( ) => ( isMounted . value ? defaultMotions . value : null ) ) ,
412428 motion : computed ( ( ) => ( isMounted . value ? props . motion : null ) ) ,
@@ -419,7 +435,7 @@ export default defineComponent({
419435 isRootMenu : ref ( true ) ,
420436 expandIcon,
421437 forceSubMenuRender : computed ( ( ) => props . forceSubMenuRender ) ,
422- rootClassName : computed ( ( ) => '' ) ,
438+ rootClassName : hashId ,
423439 } ) ;
424440 return ( ) => {
425441 const childList = itemsNodes . value || flattenChildren ( slots . default ?.( ) ) ;
@@ -442,14 +458,14 @@ export default defineComponent({
442458 ) ) ;
443459 const overflowedIndicator = slots . overflowedIndicator ?.( ) || < EllipsisOutlined /> ;
444460
445- return (
461+ return wrapSSR (
446462 < Overflow
447463 { ...attrs }
448464 onMousedown = { props . onMousedown }
449465 prefixCls = { `${ prefixCls . value } -overflow` }
450466 component = "ul"
451467 itemComponent = { MenuItem }
452- class = { [ className . value , attrs . class ] }
468+ class = { [ className . value , attrs . class , hashId . value ] }
453469 role = "menu"
454470 id = { props . id }
455471 data = { wrappedChildList }
@@ -499,7 +515,7 @@ export default defineComponent({
499515 < PathContext > { wrappedChildList } </ PathContext >
500516 </ div >
501517 </ Teleport >
502- </ Overflow >
518+ </ Overflow > ,
503519 ) ;
504520 } ;
505521 } ,
0 commit comments