From 44ad6b0c07815af694c76b327f44f37191a2a9d9 Mon Sep 17 00:00:00 2001 From: wangxing Date: Thu, 28 Mar 2019 17:04:26 +0800 Subject: [PATCH 1/2] fix-15699 --- components/menu/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/menu/index.tsx b/components/menu/index.tsx index ab4500ce14..41cfbdd2b3 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -171,10 +171,12 @@ class Menu extends React.Component { // when inlineCollapsed menu width animation finished // https://github.com/ant-design/ant-design/issues/12864 const widthCollapsed = e.propertyName === 'width' && e.target === e.currentTarget; + // Fix e.target.className.indexOf is not a function + // https://github.com/ant-design/ant-design/issues/15699 + const { className = '' } = e.target as HTMLElement; // Fix for , the width transition won't trigger when menu is collapsed // https://github.com/ant-design/ant-design-pro/issues/2783 - const iconScaled = - e.propertyName === 'font-size' && (e.target as HTMLElement).className.indexOf('anticon') >= 0; + const iconScaled = e.propertyName === 'font-size' && className.indexOf('anticon') >= 0; if (widthCollapsed || iconScaled) { this.restoreModeVerticalFromInline(); } From 1f60f379074ea382223525394511bee5aaed3ad1 Mon Sep 17 00:00:00 2001 From: wangxing Date: Fri, 29 Mar 2019 08:37:25 +0800 Subject: [PATCH 2/2] check SVGAnimatedString --- components/menu/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/menu/index.tsx b/components/menu/index.tsx index 41cfbdd2b3..b4fee34b3c 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -171,12 +171,19 @@ class Menu extends React.Component { // when inlineCollapsed menu width animation finished // https://github.com/ant-design/ant-design/issues/12864 const widthCollapsed = e.propertyName === 'width' && e.target === e.currentTarget; - // Fix e.target.className.indexOf is not a function + + // Fix SVGElement e.target.className.indexOf is not a function // https://github.com/ant-design/ant-design/issues/15699 - const { className = '' } = e.target as HTMLElement; + const { className } = e.target as (HTMLElement | SVGElement); + // SVGAnimatedString.animVal should be identical to SVGAnimatedString.baseVal, unless during an animation. + const classNameValue = + Object.prototype.toString.call(className) === '[object SVGAnimatedString]' + ? className.animVal + : className; + // Fix for , the width transition won't trigger when menu is collapsed // https://github.com/ant-design/ant-design-pro/issues/2783 - const iconScaled = e.propertyName === 'font-size' && className.indexOf('anticon') >= 0; + const iconScaled = e.propertyName === 'font-size' && classNameValue.indexOf('anticon') >= 0; if (widthCollapsed || iconScaled) { this.restoreModeVerticalFromInline(); }