mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
chore: warning divider not support text (#37697)
This commit is contained in:
parent
a6e620c975
commit
af32d24b5f
@ -1,6 +0,0 @@
|
|||||||
import Divider from '..';
|
|
||||||
import mountTest from '../../../tests/shared/mountTest';
|
|
||||||
|
|
||||||
describe('Divider', () => {
|
|
||||||
mountTest(Divider);
|
|
||||||
});
|
|
17
components/divider/__tests__/index.test.tsx
Normal file
17
components/divider/__tests__/index.test.tsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { render } from '../../../tests/utils';
|
||||||
|
import Divider from '..';
|
||||||
|
import mountTest from '../../../tests/shared/mountTest';
|
||||||
|
|
||||||
|
describe('Divider', () => {
|
||||||
|
mountTest(Divider);
|
||||||
|
|
||||||
|
it('not show children when vertical', () => {
|
||||||
|
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
|
||||||
|
const { container } = render(<Divider type="vertical">Bamboo</Divider>);
|
||||||
|
expect(container.querySelector('.ant-divider-inner-text')).toBeFalsy();
|
||||||
|
|
||||||
|
errSpy.mockRestore();
|
||||||
|
});
|
||||||
|
});
|
@ -1,6 +1,7 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ConfigContext } from '../config-provider';
|
import { ConfigContext } from '../config-provider';
|
||||||
|
import warning from '../_util/warning';
|
||||||
|
|
||||||
export interface DividerProps {
|
export interface DividerProps {
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
@ -53,9 +54,18 @@ const Divider: React.FC<DividerProps> = props => {
|
|||||||
...(hasCustomMarginRight && { marginRight: orientationMargin }),
|
...(hasCustomMarginRight && { marginRight: orientationMargin }),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Warning children not work in vertical mode
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
warning(
|
||||||
|
!children || type !== 'vertical',
|
||||||
|
'Divider',
|
||||||
|
'`children` not working in `vertical` mode.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classString} {...restProps} role="separator">
|
<div className={classString} {...restProps} role="separator">
|
||||||
{children && (
|
{children && type !== 'vertical' && (
|
||||||
<span className={`${prefixCls}-inner-text`} style={innerStyle}>
|
<span className={`${prefixCls}-inner-text`} style={innerStyle}>
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user