fix #12539. delay also double confirm spin status.

This commit is contained in:
zombiej 2018-10-09 00:02:03 +08:00
parent 00d1a26d4e
commit f9c2310424

View File

@ -96,7 +96,7 @@ class Spin extends React.Component<SpinProps, SpinState> {
componentDidMount() {
const { spinning, delay } = this.props;
if (shouldDelay(spinning, delay)) {
this.delayTimeout = window.setTimeout(() => this.setState({ spinning }), delay);
this.delayTimeout = window.setTimeout(this.delayUpdateSpinning, delay);
}
}
@ -126,17 +126,24 @@ class Spin extends React.Component<SpinProps, SpinState> {
clearTimeout(this.delayTimeout);
}
} else {
if (spinning && delay && !isNaN(Number(delay))) {
if (shouldDelay(spinning, delay)) {
if (this.delayTimeout) {
clearTimeout(this.delayTimeout);
}
this.delayTimeout = window.setTimeout(() => this.setState({ spinning }), delay);
this.delayTimeout = window.setTimeout(this.delayUpdateSpinning, delay);
} else {
this.setState({ spinning });
}
}
}
delayUpdateSpinning = () => {
const { spinning } = this.props;
if (this.state.spinning !== spinning) {
this.setState({ spinning });
}
};
render() {
const { className, size, prefixCls, tip, wrapperClassName, ...restProps } = this.props;
const { spinning } = this.state;