Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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