Skip to content

Commit

Permalink
fix: Menu miss pass the style into sub MenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jun 5, 2019
1 parent 4f839f8 commit 6784ad1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/DOMWrap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ class DOMWrap extends React.Component {
}

getOverflowedSubMenuItem = (keyPrefix, overflowedItems, renderPlaceholder) => {
const { overflowedIndicator, level, mode, prefixCls, theme, style: propStyle } = this.props;
const { overflowedIndicator, level, mode, prefixCls, theme } = this.props;
if (level !== 1 || mode !== 'horizontal') {
return null;
}
// put all the overflowed item inside a submenu
// with a title of overflow indicator ('...')
const copy = this.props.children[0];
const { children: throwAway, title, ...rest } = copy.props;
const { children: throwAway, title, style: propStyle, ...rest } = copy.props;

let style = { ...propStyle };
let key = `${keyPrefix}-overflowed-indicator`;
Expand Down
34 changes: 30 additions & 4 deletions tests/SubPopupMenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { mount } from 'enzyme';
import { saveRef } from '../src/SubPopupMenu';
import Menu, { MenuItem } from '../src';

describe('SubPopupMenu saveRef', () => {
describe('SubPopupMenu', () => {
let subPopupMenu;


beforeEach(() => {
subPopupMenu = { instanceArray: [] };
});
Expand All @@ -30,11 +29,14 @@ describe('SubPopupMenu saveRef', () => {
<Menu activeKey="1">
<MenuItem key="1">1</MenuItem>
<MenuItem key="2">2</MenuItem>
</Menu>
</Menu>,
);

function getItemActive(index) {
return wrapper.find('MenuItem').at(index).instance().props.active;
return wrapper
.find('MenuItem')
.at(index)
.instance().props.active;
}
expect(getItemActive(0)).toBe(true);
expect(getItemActive(1)).toBe(false);
Expand All @@ -44,4 +46,28 @@ describe('SubPopupMenu saveRef', () => {
expect(getItemActive(0)).toBe(false);
expect(getItemActive(1)).toBe(true);
});

it('not pass style into sub menu item', () => {
const wrapper = mount(
<Menu mode="horizontal" style={{ background: 'green' }}>
<MenuItem style={{ color: 'red' }} key="1">
1
</MenuItem>
</Menu>,
);

expect(
wrapper
.find('li.rc-menu-overflowed-submenu')
.at(0)
.props().style,
).toEqual({ color: 'red', display: 'none' });

expect(
wrapper
.find('li.rc-menu-item')
.at(0)
.props().style,
).toEqual({ color: 'red' });
});
});

1 comment on commit 6784ad1

@afc163
Copy link
Member

@afc163 afc163 commented on 6784ad1 Jun 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

导致 antd 的 snapshot 挂了,看看会不会有问题。

https://circleci.com/gh/ant-design/ant-design/85898

Please sign in to comment.