mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
chore: Add warning if use inlineCollapsed
under Sider (#16826)
This commit is contained in:
parent
9b05885363
commit
93887e1380
@ -138,7 +138,17 @@ describe('Layout', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Sider onBreakpoint', () => {
|
describe('Sider', () => {
|
||||||
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
errorSpy.mockReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
errorSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
Object.defineProperty(window, 'matchMedia', {
|
Object.defineProperty(window, 'matchMedia', {
|
||||||
value: jest.fn(() => ({
|
value: jest.fn(() => ({
|
||||||
@ -159,4 +169,15 @@ describe('Sider onBreakpoint', () => {
|
|||||||
);
|
);
|
||||||
expect(onBreakpoint).toHaveBeenCalledWith(true);
|
expect(onBreakpoint).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should warning if use `inlineCollapsed` with menu', () => {
|
||||||
|
mount(
|
||||||
|
<Sider collapsible>
|
||||||
|
<Menu mode="inline" inlineCollapsed />
|
||||||
|
</Sider>,
|
||||||
|
);
|
||||||
|
expect(errorSpy).toHaveBeenCalledWith(
|
||||||
|
'Warning: [antd: Menu] `inlineCollapsed` not control Menu under Sider. Should set `collapsed` on Sider instead.',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -142,6 +142,12 @@ class InternalMenu extends React.Component<InternalMenuProps, MenuState> {
|
|||||||
'`inlineCollapsed` should only be used when `mode` is inline.',
|
'`inlineCollapsed` should only be used when `mode` is inline.',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
warning(
|
||||||
|
!(props.siderCollapsed !== undefined && 'inlineCollapsed' in props),
|
||||||
|
'Menu',
|
||||||
|
'`inlineCollapsed` not control Menu under Sider. Should set `collapsed` on Sider instead.',
|
||||||
|
);
|
||||||
|
|
||||||
let openKeys;
|
let openKeys;
|
||||||
if ('openKeys' in props) {
|
if ('openKeys' in props) {
|
||||||
openKeys = props.openKeys;
|
openKeys = props.openKeys;
|
||||||
|
Loading…
Reference in New Issue
Block a user