Browse Source
Merge pull request #15396 from SoraYama/sorayama
fix(Layout): disable `hasSider` when specifically declared
pull/15421/head
偏右
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
11 additions and
1 deletions
-
components/layout/__tests__/index.test.js
-
components/layout/layout.tsx
|
|
@ -95,6 +95,15 @@ describe('Layout', () => { |
|
|
|
wrapper.setProps({ collapsed: true }); |
|
|
|
expect(wrapper.instance().state.collapsed).toBe(true); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not add ant-layout-has-sider when `hasSider` is `false`', () => { |
|
|
|
const wrapper = mount( |
|
|
|
<Layout hasSider={false}> |
|
|
|
<Sider>Sider</Sider> |
|
|
|
</Layout>, |
|
|
|
); |
|
|
|
expect(wrapper.find('.ant-layout').hasClass('ant-layout-has-sider')).toBe(false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Sider onBreakpoint', () => { |
|
|
|
|
|
@ -77,7 +77,8 @@ class BasicLayout extends React.Component<BasicPropsWithTagName, BasicLayoutStat |
|
|
|
render() { |
|
|
|
const { prefixCls, className, children, hasSider, tagName, ...others } = this.props; |
|
|
|
const classString = classNames(className, prefixCls, { |
|
|
|
[`${prefixCls}-has-sider`]: hasSider || this.state.siders.length > 0, |
|
|
|
[`${prefixCls}-has-sider`]: |
|
|
|
typeof hasSider === 'boolean' ? hasSider : this.state.siders.length > 0, |
|
|
|
}); |
|
|
|
return React.createElement(tagName, { className: classString, ...others }, children); |
|
|
|
} |
|
|
|