Skip to content

Commit 8f41453

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

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/ResizableTextArea.tsx

Lines changed: 8 additions & 5 deletions
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 {
@@ -109,7 +109,10 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
109109
// https://github.com/ant-design/ant-design/issues/21870
110110
fixFirefoxAutoScroll() {
111111
try {
112-
if (document.activeElement === this.textArea) {
112+
if (
113+
window.hasOwnProperty('mozInnerScreenX') &&
114+
document.activeElement === this.textArea
115+
) {
113116
const currentStart = this.textArea.selectionStart;
114117
const currentEnd = this.textArea.selectionEnd;
115118
this.textArea.setSelectionRange(currentStart, currentEnd);

tests/index.spec.js

Lines changed: 2 additions & 2 deletions
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

@@ -241,6 +240,7 @@ describe('TextArea', () => {
241240
});
242241

243242
it('scroll to bottom when autoSize', async () => {
243+
window.mozInnerScreenX = 0;
244244
const wrapper = mount(<TextArea autoSize />, { attachTo: document.body });
245245
wrapper.find('textarea').simulate('focus');
246246
wrapper.find('textarea').getDOMNode().focus();

0 commit comments

Comments
 (0)