fix: menu title logic
parent
d54833b3bb
commit
5dbcba196f
|
@ -3,7 +3,7 @@ import { Item, itemProps } from '../vc-menu';
|
||||||
import { getOptionProps, getSlot } from '../_util/props-util';
|
import { getOptionProps, getSlot } from '../_util/props-util';
|
||||||
import Tooltip, { TooltipProps } from '../tooltip';
|
import Tooltip, { TooltipProps } from '../tooltip';
|
||||||
import { SiderContextProps } from '../layout/Sider';
|
import { SiderContextProps } from '../layout/Sider';
|
||||||
|
import { injectExtraPropsKey } from '../vc-menu/FunctionProvider';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'MenuItem',
|
name: 'MenuItem',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
@ -13,6 +13,7 @@ export default defineComponent({
|
||||||
return {
|
return {
|
||||||
getInlineCollapsed: inject<() => boolean>('getInlineCollapsed', () => false),
|
getInlineCollapsed: inject<() => boolean>('getInlineCollapsed', () => false),
|
||||||
layoutSiderContext: inject<SiderContextProps>('layoutSiderContext', {}),
|
layoutSiderContext: inject<SiderContextProps>('layoutSiderContext', {}),
|
||||||
|
injectExtraProps: inject(injectExtraPropsKey, () => ({})),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -22,7 +23,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const props = getOptionProps(this);
|
const props = getOptionProps(this);
|
||||||
const { level, title, rootPrefixCls } = props;
|
const { level, title, rootPrefixCls } = { ...props, ...this.injectExtraProps } as any;
|
||||||
const { getInlineCollapsed, $attrs: attrs } = this;
|
const { getInlineCollapsed, $attrs: attrs } = this;
|
||||||
const inlineCollapsed = getInlineCollapsed();
|
const inlineCollapsed = getInlineCollapsed();
|
||||||
let tooltipTitle = title;
|
let tooltipTitle = title;
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
import PropTypes from '../_util/vue-types';
|
// import PropTypes from '../_util/vue-types';
|
||||||
import { provide, reactive } from 'vue';
|
import { provide, reactive } from 'vue';
|
||||||
|
export const injectExtraPropsKey = Symbol();
|
||||||
const FunctionProvider = {
|
const FunctionProvider = {
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
|
||||||
injectExtraPropsKey: PropTypes.string,
|
|
||||||
},
|
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
if (props.injectExtraPropsKey) {
|
provide(injectExtraPropsKey, reactive(attrs));
|
||||||
provide(props.injectExtraPropsKey, reactive(attrs));
|
|
||||||
}
|
|
||||||
return () => slots.default?.();
|
return () => slots.default?.();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { connect } from '../_util/store';
|
||||||
import { noop, menuAllProps } from './util';
|
import { noop, menuAllProps } from './util';
|
||||||
import { getComponent, getSlot, findDOMNode } from '../_util/props-util';
|
import { getComponent, getSlot, findDOMNode } from '../_util/props-util';
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
const injectExtraPropsKey = 'ANT_MENU_PROVIDER_PROPS_KEY';
|
import { injectExtraPropsKey } from './FunctionProvider';
|
||||||
const props = {
|
const props = {
|
||||||
attribute: PropTypes.object,
|
attribute: PropTypes.object,
|
||||||
rootPrefixCls: PropTypes.string,
|
rootPrefixCls: PropTypes.string,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { getComponent, getSlot } from '../_util/props-util';
|
||||||
import { menuAllProps } from './util';
|
import { menuAllProps } from './util';
|
||||||
import { defineComponent, inject } from 'vue';
|
import { defineComponent, inject } from 'vue';
|
||||||
import classNames from '../_util/classNames';
|
import classNames from '../_util/classNames';
|
||||||
const injectExtraPropsKey = 'ANT_MENU_PROVIDER_PROPS_KEY';
|
import { injectExtraPropsKey } from './FunctionProvider';
|
||||||
const MenuItemGroup = {
|
const MenuItemGroup = {
|
||||||
name: 'MenuItemGroup',
|
name: 'MenuItemGroup',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
|
|
@ -11,9 +11,9 @@ import { getComponent, filterEmpty, getSlot, splitAttrs, findDOMNode } from '../
|
||||||
import { requestAnimationTimeout, cancelAnimationTimeout } from '../_util/requestAnimationTimeout';
|
import { requestAnimationTimeout, cancelAnimationTimeout } from '../_util/requestAnimationTimeout';
|
||||||
import { noop, loopMenuItemRecursively, getMenuIdFromSubMenuEventKey } from './util';
|
import { noop, loopMenuItemRecursively, getMenuIdFromSubMenuEventKey } from './util';
|
||||||
import { getTransitionProps, Transition } from '../_util/transition';
|
import { getTransitionProps, Transition } from '../_util/transition';
|
||||||
|
import { injectExtraPropsKey } from './FunctionProvider';
|
||||||
|
|
||||||
let guid = 0;
|
let guid = 0;
|
||||||
const injectExtraPropsKey = 'ANT_MENU_PROVIDER_PROPS_KEY';
|
|
||||||
const popupPlacementMap = {
|
const popupPlacementMap = {
|
||||||
horizontal: 'bottomLeft',
|
horizontal: 'bottomLeft',
|
||||||
vertical: 'rightTop',
|
vertical: 'rightTop',
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
getPropsData,
|
getPropsData,
|
||||||
} from '../_util/props-util';
|
} from '../_util/props-util';
|
||||||
import FunctionProvider from './FunctionProvider';
|
import FunctionProvider from './FunctionProvider';
|
||||||
const injectExtraPropsKey = 'ANT_MENU_PROVIDER_PROPS_KEY';
|
|
||||||
function allDisabled(arr) {
|
function allDisabled(arr) {
|
||||||
if (!arr.length) {
|
if (!arr.length) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -323,11 +322,7 @@ const SubPopupMenu = {
|
||||||
if (props.mode === 'inline' || isMobileDevice()) {
|
if (props.mode === 'inline' || isMobileDevice()) {
|
||||||
newChildProps.triggerSubMenuAction = 'click';
|
newChildProps.triggerSubMenuAction = 'click';
|
||||||
}
|
}
|
||||||
return (
|
return <FunctionProvider {...newChildProps}>{child}</FunctionProvider>;
|
||||||
<FunctionProvider injectExtraPropsKey={injectExtraPropsKey} {...newChildProps}>
|
|
||||||
{child}
|
|
||||||
</FunctionProvider>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
renderMenuItem(c, i, subMenuKey) {
|
renderMenuItem(c, i, subMenuKey) {
|
||||||
|
|
Loading…
Reference in New Issue