Browse Source

Merge pull request #15720 from wx1322/check-className

Layout.Sider of collapsible type throws error
pull/15747/head
ztplz 6 years ago
committed by GitHub
parent
commit
55c1be3b54
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      components/menu/index.tsx

13
components/menu/index.tsx

@ -171,10 +171,19 @@ class Menu extends React.Component<MenuProps, MenuState> {
// when inlineCollapsed menu width animation finished // when inlineCollapsed menu width animation finished
// https://github.com/ant-design/ant-design/issues/12864 // https://github.com/ant-design/ant-design/issues/12864
const widthCollapsed = e.propertyName === 'width' && e.target === e.currentTarget; const widthCollapsed = e.propertyName === 'width' && e.target === e.currentTarget;
// 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 | 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 <Menu style={{ width: '100%' }} />, the width transition won't trigger when menu is collapsed // Fix for <Menu style={{ width: '100%' }} />, the width transition won't trigger when menu is collapsed
// https://github.com/ant-design/ant-design-pro/issues/2783 // https://github.com/ant-design/ant-design-pro/issues/2783
const iconScaled = const iconScaled = e.propertyName === 'font-size' && classNameValue.indexOf('anticon') >= 0;
e.propertyName === 'font-size' && (e.target as HTMLElement).className.indexOf('anticon') >= 0;
if (widthCollapsed || iconScaled) { if (widthCollapsed || iconScaled) {
this.restoreModeVerticalFromInline(); this.restoreModeVerticalFromInline();
} }

Loading…
Cancel
Save