|
|
@ -65,6 +65,7 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> { |
|
|
|
raf.cancel(this.resizeFrameId); |
|
|
|
this.resizeFrameId = raf(() => { |
|
|
|
this.setState({ resizing: false }); |
|
|
|
this.fixFirefoxAutoScroll(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -74,6 +75,21 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> { |
|
|
|
raf.cancel(this.resizeFrameId); |
|
|
|
} |
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/21870
|
|
|
|
fixFirefoxAutoScroll() { |
|
|
|
try { |
|
|
|
if (document.activeElement === this.textArea) { |
|
|
|
const currentStart = this.textArea.selectionStart; |
|
|
|
const currentEnd = this.textArea.selectionEnd; |
|
|
|
this.textArea.setSelectionRange(currentStart, currentEnd); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
// Fix error in Chrome:
|
|
|
|
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
|
|
|
// http://stackoverflow.com/q/21177489/3040605
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
renderTextArea = () => { |
|
|
|
const { prefixCls, autoSize, autosize, className, disabled } = this.props; |
|
|
|
const { textareaStyles, resizing } = this.state; |
|
|
|