Skip to content

Commit

Permalink
fix: Inconsistent use of accents in Safari #16
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktail committed Jul 22, 2022
1 parent 12dc37f commit 8f41453
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/ResizableTextArea.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -109,7 +109,10 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
// https://github.com/ant-design/ant-design/issues/21870
fixFirefoxAutoScroll() {
try {
if (document.activeElement === this.textArea) {
if (
window.hasOwnProperty('mozInnerScreenX') &&
document.activeElement === this.textArea
) {
const currentStart = this.textArea.selectionStart;
const currentEnd = this.textArea.selectionEnd;
this.textArea.setSelectionRange(currentStart, currentEnd);
Expand Down
4 changes: 2 additions & 2 deletions tests/index.spec.js
Original file line number Diff line number Diff line change
@@ -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);

Expand Down Expand Up @@ -241,6 +240,7 @@ describe('TextArea', () => {
});

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

0 comments on commit 8f41453

Please sign in to comment.