mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-13 04:53:11 +08:00
Fix click effect in Popconfirm button
This commit is contained in:
parent
7518e30c3f
commit
f7fb5b29f9
@ -24,13 +24,19 @@ function insertSpace(child) {
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearButton(button) {
|
||||||
|
button.className = button.className.replace(`${prefix}clicked`, '');
|
||||||
|
}
|
||||||
|
|
||||||
export default class Button extends React.Component {
|
export default class Button extends React.Component {
|
||||||
handleClick(...args) {
|
handleClick(...args) {
|
||||||
|
// Add click effect
|
||||||
const buttonNode = findDOMNode(this);
|
const buttonNode = findDOMNode(this);
|
||||||
buttonNode.className = buttonNode.className.replace(`${prefix}clicked`, '');
|
clearButton(buttonNode);
|
||||||
setTimeout(() => {
|
setTimeout(() => buttonNode.className += ` ${prefix}clicked`, 10);
|
||||||
buttonNode.className += ` ${prefix}clicked`;
|
clearTimeout(this.timeout);
|
||||||
}, 10);
|
this.timeout = setTimeout(() => clearButton(buttonNode), 500);
|
||||||
|
|
||||||
this.props.onClick(...args);
|
this.props.onClick(...args);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
@ -50,13 +56,16 @@ export default class Button extends React.Component {
|
|||||||
[prefix + shape]: shape,
|
[prefix + shape]: shape,
|
||||||
[prefix + sizeCls]: sizeCls,
|
[prefix + sizeCls]: sizeCls,
|
||||||
[`${prefix}loading`]: ('loading' in props && props.loading !== false),
|
[`${prefix}loading`]: ('loading' in props && props.loading !== false),
|
||||||
[className]: className
|
[className]: className,
|
||||||
});
|
});
|
||||||
|
|
||||||
const kids = React.Children.map(children, insertSpace);
|
const kids = React.Children.map(children, insertSpace);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button {...others} type={htmlType || 'button'} className={classes} onClick={this.handleClick.bind(this)}>
|
<button {...others}
|
||||||
|
type={htmlType || 'button'}
|
||||||
|
className={classes}
|
||||||
|
onClick={this.handleClick.bind(this)}>
|
||||||
{kids}
|
{kids}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user