From 44ccaa17de5d291ef7a796c8e112a59e49003be3 Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Tue, 25 May 2021 11:20:06 +0800 Subject: [PATCH] feat: update --- components/anchor/Anchor.tsx | 12 ++++-------- components/menu/src/SubMenu.tsx | 10 ++++++++-- components/menu/style/index.less | 5 +++++ v2-doc | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/anchor/Anchor.tsx b/components/anchor/Anchor.tsx index 7797539fd..62e599f27 100644 --- a/components/anchor/Anchor.tsx +++ b/components/anchor/Anchor.tsx @@ -95,12 +95,6 @@ export default defineComponent({ }); // func... const getCurrentAnchor = (offsetTop = 0, bounds = 5) => { - const { getCurrentAnchor } = props; - - if (typeof getCurrentAnchor === 'function') { - return getCurrentAnchor(); - } - const linkSections: Array
= []; const container = getContainer.value(); state.links.forEach(link => { @@ -127,10 +121,12 @@ export default defineComponent({ return ''; }; const setCurrentActiveLink = (link: string) => { + const { getCurrentAnchor } = props; if (activeLink.value !== link) { - activeLink.value = link; - emit('change', link); + return; } + activeLink.value = typeof getCurrentAnchor === 'function' ? getCurrentAnchor() : link; + emit('change', link); }; const handleScrollTo = (link: string) => { const { offsetTop, getContainer, targetOffset } = props; diff --git a/components/menu/src/SubMenu.tsx b/components/menu/src/SubMenu.tsx index 355ec3b9e..1051c5847 100644 --- a/components/menu/src/SubMenu.tsx +++ b/components/menu/src/SubMenu.tsx @@ -18,6 +18,7 @@ import PopupTrigger from './PopupTrigger'; import SubMenuList from './SubMenuList'; import InlineSubMenuList from './InlineSubMenuList'; import Transition, { getTransitionProps } from '../../_util/transition'; +import { cloneElement } from '../../_util/vnode'; let indexGuid = 0; @@ -177,7 +178,10 @@ export default defineComponent({ ); const renderTitle = (title: any, icon: any) => { if (!icon) { - return inlineCollapsed.value && props.level === 1 && title && typeof title === 'string' ? ( + return inlineCollapsed.value && + !parentEventKeys.value.length && + title && + typeof title === 'string' ? (
{title.charAt(0)}
) : ( title @@ -188,7 +192,9 @@ export default defineComponent({ const titleIsSpan = isValidElement(title) && title.type === 'span'; return ( <> - {icon} + {cloneElement(icon, { + class: `${prefixCls.value}-item-icon`, + })} {titleIsSpan ? title : {title}} ); diff --git a/components/menu/style/index.less b/components/menu/style/index.less index b14e86259..2b330a256 100644 --- a/components/menu/style/index.less +++ b/components/menu/style/index.less @@ -218,6 +218,10 @@ } } + .@{menu-prefix-cls}-item-icon.svg { + vertical-align: -0.125em; + } + &.@{menu-prefix-cls}-item-only-child { > .@{iconfont-css-prefix}, > .@{menu-prefix-cls}-item-icon { @@ -530,6 +534,7 @@ text-overflow: clip; .@{menu-prefix-cls}-submenu-arrow { + opacity: 0; display: none; } diff --git a/v2-doc b/v2-doc index d19705328..a7013ae87 160000 --- a/v2-doc +++ b/v2-doc @@ -1 +1 @@ -Subproject commit d197053285b81e77718621c0b5b94cb3b21831a2 +Subproject commit a7013ae87f69dcbcf547f4b023255b8a7a775557