Skip to content

Commit b63ed56

Browse files
committed
fix: Inconsistent use of accents in Safari #16
1 parent 12dc37f commit b63ed56

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

src/ResizableTextArea.tsx

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as React from 'react';
1+
import classNames from 'classnames';
22
import ResizeObserver from 'rc-resize-observer';
33
import omit from 'rc-util/lib/omit';
4-
import classNames from 'classnames';
5-
import calculateNodeHeight from './calculateNodeHeight';
6-
import type { TextAreaProps } from '.';
4+
import * as React from 'react';
75
import shallowEqual from 'shallowequal';
6+
import type { TextAreaProps } from '.';
7+
import calculateNodeHeight from './calculateNodeHeight';
88

99
// eslint-disable-next-line @typescript-eslint/naming-convention
1010
enum RESIZE_STATUS {
@@ -93,7 +93,6 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
9393
this.setState({ resizeStatus: RESIZE_STATUS.RESIZED }, () => {
9494
this.resizeFrameId = requestAnimationFrame(() => {
9595
this.setState({ resizeStatus: RESIZE_STATUS.NONE });
96-
this.fixFirefoxAutoScroll();
9796
});
9897
});
9998
});
@@ -106,21 +105,6 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
106105
cancelAnimationFrame(this.resizeFrameId);
107106
}
108107

109-
// https://github.com/ant-design/ant-design/issues/21870
110-
fixFirefoxAutoScroll() {
111-
try {
112-
if (document.activeElement === this.textArea) {
113-
const currentStart = this.textArea.selectionStart;
114-
const currentEnd = this.textArea.selectionEnd;
115-
this.textArea.setSelectionRange(currentStart, currentEnd);
116-
}
117-
} catch (e) {
118-
// Fix error in Chrome:
119-
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
120-
// http://stackoverflow.com/q/21177489/3040605
121-
}
122-
}
123-
124108
renderTextArea = () => {
125109
const {
126110
prefixCls = 'rc-textarea',

tests/index.spec.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React from 'react';
21
import { mount } from 'enzyme';
32
import TextArea from '../src';
4-
import { focusTest, sleep } from './utils';
53
import calculateNodeHeight, {
64
calculateNodeStyling,
75
} from '../src/calculateNodeHeight';
6+
import { focusTest, sleep } from './utils';
87

98
focusTest(TextArea);
109

@@ -239,18 +238,4 @@ describe('TextArea', () => {
239238
}),
240239
);
241240
});
242-
243-
it('scroll to bottom when autoSize', async () => {
244-
const wrapper = mount(<TextArea autoSize />, { attachTo: document.body });
245-
wrapper.find('textarea').simulate('focus');
246-
wrapper.find('textarea').getDOMNode().focus();
247-
const setSelectionRangeFn = jest.spyOn(
248-
wrapper.find('textarea').getDOMNode(),
249-
'setSelectionRange',
250-
);
251-
wrapper.find('textarea').simulate('change', { target: { value: '\n1' } });
252-
await sleep(100);
253-
expect(setSelectionRangeFn).toHaveBeenCalled();
254-
wrapper.unmount();
255-
});
256241
});

0 commit comments

Comments
 (0)