diff --git a/src/ResizableTextArea.tsx b/src/ResizableTextArea.tsx index d20b96f..8912ec3 100644 --- a/src/ResizableTextArea.tsx +++ b/src/ResizableTextArea.tsx @@ -1,8 +1,8 @@ -import classNames from 'classnames'; import ResizeObserver from '@rc-component/resize-observer'; import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; import raf from '@rc-component/util/lib/raf'; +import classNames from 'classnames'; import * as React from 'react'; import type { TextAreaProps } from '.'; import calculateAutoSizeStyle from './calculateNodeHeight'; @@ -66,9 +66,10 @@ const ResizableTextArea = React.forwardRef( // https://github.com/ant-design/ant-design/issues/21870 const fixFirefoxAutoScroll = () => { try { + const isFirefox = navigator.userAgent.includes('Firefox'); // FF has bug with jump of scroll to top. We force back here. - if (document.activeElement === textareaRef.current) { - const { selectionStart, selectionEnd, scrollTop } = + if (isFirefox && document.activeElement === textareaRef.current) { + const { scrollTop, selectionStart, selectionEnd } = textareaRef.current; // Fix Safari bug which not rollback when break line diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 3703230..ff59503 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -37,6 +37,42 @@ describe('TextArea', () => { jest.useRealTimers(); }); + it('paste text should change cursor position', async () => { + const { container } = render( +