diff --git a/src/ResizableTextArea.tsx b/src/ResizableTextArea.tsx index 595f455..c3f78b6 100644 --- a/src/ResizableTextArea.tsx +++ b/src/ResizableTextArea.tsx @@ -1,10 +1,10 @@ -import * as React from 'react'; +import classNames from 'classnames'; import ResizeObserver from 'rc-resize-observer'; import omit from 'rc-util/lib/omit'; -import classNames from 'classnames'; -import calculateNodeHeight from './calculateNodeHeight'; -import type { TextAreaProps } from '.'; +import * as React from 'react'; import shallowEqual from 'shallowequal'; +import type { TextAreaProps } from '.'; +import calculateNodeHeight from './calculateNodeHeight'; // eslint-disable-next-line @typescript-eslint/naming-convention enum RESIZE_STATUS { @@ -93,7 +93,6 @@ class ResizableTextArea extends React.Component { this.setState({ resizeStatus: RESIZE_STATUS.RESIZED }, () => { this.resizeFrameId = requestAnimationFrame(() => { this.setState({ resizeStatus: RESIZE_STATUS.NONE }); - this.fixFirefoxAutoScroll(); }); }); }); @@ -106,21 +105,6 @@ class ResizableTextArea extends React.Component { cancelAnimationFrame(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 = 'rc-textarea', diff --git a/tests/index.spec.js b/tests/index.spec.js index 3fd5035..2d74751 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -1,10 +1,9 @@ -import React from 'react'; import { mount } from 'enzyme'; import TextArea from '../src'; -import { focusTest, sleep } from './utils'; import calculateNodeHeight, { calculateNodeStyling, } from '../src/calculateNodeHeight'; +import { focusTest, sleep } from './utils'; focusTest(TextArea); @@ -239,18 +238,4 @@ describe('TextArea', () => { }), ); }); - - it('scroll to bottom when autoSize', async () => { - const wrapper = mount(