mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
findDOMNode to refs, close #12843
This commit is contained in:
parent
de492b90a4
commit
087f7efd10
@ -1,5 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import { findDOMNode } from 'react-dom';
|
||||
import * as PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import Wave from '../_util/wave';
|
||||
@ -89,6 +88,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
};
|
||||
|
||||
private delayTimeout: number;
|
||||
private buttonNode: HTMLElement | null;
|
||||
|
||||
constructor(props: ButtonProps) {
|
||||
super(props);
|
||||
@ -127,10 +127,16 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
}
|
||||
}
|
||||
|
||||
saveButtonRef = (node: HTMLElement | null) => {
|
||||
this.buttonNode = node;
|
||||
}
|
||||
|
||||
fixTwoCNChar() {
|
||||
// Fix for HOC usage like <FormatMessage />
|
||||
const node = (findDOMNode(this) as HTMLElement);
|
||||
const buttonText = node.textContent || node.innerText;
|
||||
if (!this.buttonNode) {
|
||||
return;
|
||||
}
|
||||
const buttonText = this.buttonNode.textContent || this.buttonNode.innerText;
|
||||
if (this.isNeedInserted() && isTwoCNChar(buttonText)) {
|
||||
if (!this.state.hasTwoCNChar) {
|
||||
this.setState({
|
||||
@ -208,6 +214,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
className={classes}
|
||||
onClick={this.handleClick}
|
||||
title={title}
|
||||
ref={this.saveButtonRef}
|
||||
>
|
||||
{iconNode}{kids}
|
||||
</a>
|
||||
@ -224,6 +231,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
className={classes}
|
||||
onClick={this.handleClick}
|
||||
title={title}
|
||||
ref={this.saveButtonRef}
|
||||
>
|
||||
{iconNode}{kids}
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user