mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
fix: should not be render default indicator when indicator value is null (#19943)
This commit is contained in:
parent
c7810823bf
commit
bed1f7775b
@ -1,5 +1,18 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Spin if indicator set null should not be render default indicator 1`] = `
|
||||
<Spin
|
||||
indicator={null}
|
||||
size="default"
|
||||
spinning={true}
|
||||
wrapperClassName=""
|
||||
>
|
||||
<div
|
||||
className="ant-spin ant-spin-spinning"
|
||||
/>
|
||||
</Spin>
|
||||
`;
|
||||
|
||||
exports[`Spin should render custom indicator when it's set 1`] = `
|
||||
<div
|
||||
class="ant-spin ant-spin-spinning"
|
||||
|
@ -38,4 +38,9 @@ describe('Spin', () => {
|
||||
wrapper.setProps({ spinning: true });
|
||||
expect(wrapper.instance().state.spinning).toBe(true);
|
||||
});
|
||||
|
||||
it('if indicator set null should not be render default indicator', () => {
|
||||
const wrapper = mount(<Spin indicator={null} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||
import { tuple } from '../_util/type';
|
||||
|
||||
const SpinSizes = tuple('small', 'default', 'large');
|
||||
export type SpinSize = (typeof SpinSizes)[number];
|
||||
export type SpinSize = typeof SpinSizes[number];
|
||||
export type SpinIndicator = React.ReactElement<HTMLElement>;
|
||||
|
||||
export interface SpinProps {
|
||||
@ -33,6 +33,12 @@ let defaultIndicator: React.ReactNode = null;
|
||||
function renderIndicator(prefixCls: string, props: SpinProps): React.ReactNode {
|
||||
const { indicator } = props;
|
||||
const dotClassName = `${prefixCls}-dot`;
|
||||
|
||||
// should not be render default indicator when indicator value is null
|
||||
if (indicator === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (React.isValidElement(indicator)) {
|
||||
return React.cloneElement(indicator, {
|
||||
className: classNames(indicator.props.className, dotClassName),
|
||||
|
Loading…
Reference in New Issue
Block a user