Skip to content

Commit 6420856

Browse files
fix: correct TextArea import in tests (#164)
* feat: migrate textarea implementation into rc-input * refactor(input): extract shared count display state for input and textarea * fix: lint * fix: test case * fix(input): avoid restoring stale selection after rerender * refactor(input): export textarea separately from rc-input * fix: test import * fix: import * Update tests/TextArea.focus.test.tsx Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update tests/TextArea.test.tsx Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 841fcc0 commit 6420856

9 files changed

+9
-29
lines changed

docs/examples/textarea-allow-clear.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-console */
2-
import Input from '@rc-component/input';
2+
import { TextArea } from '@rc-component/input';
33
import React, { useState, type ChangeEvent } from 'react';
44

5-
const TextArea = Input.TextArea;
6-
75
export default function App() {
86
const [value, setValue] = useState('hello\nworld');
97

docs/examples/textarea-auto-size.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-console */
2-
import Input, { type TextAreaProps } from '@rc-component/input';
2+
import { TextArea, type TextAreaProps } from '@rc-component/input';
33
import React, { useState, type ChangeEvent } from 'react';
44

5-
const TextArea = Input.TextArea;
6-
75
export default function App() {
86
const [value, setValue] = useState('hello\nworld');
97

docs/examples/textarea-basic.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-console */
2-
import Input, { type TextAreaProps } from '@rc-component/input';
2+
import { TextArea, type TextAreaProps } from '@rc-component/input';
33
import React, { useState, type ChangeEvent, type KeyboardEvent } from 'react';
44

5-
const TextArea = Input.TextArea;
6-
75
export default function App() {
86
const [value, setValue] = useState('');
97

docs/examples/textarea-show-count.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* eslint-disable no-console */
2-
import Input from '@rc-component/input';
2+
import { TextArea } from '@rc-component/input';
33
import React, { useState, type ChangeEvent } from 'react';
44
import '../../assets/index.less';
55

6-
const TextArea = Input.TextArea;
7-
86
export default function App() {
97
const [value, setValue] = useState('hello\nworld');
108

tests/TextArea.allowClear.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { fireEvent, render } from '@testing-library/react';
22
import type { ChangeEventHandler, TextareaHTMLAttributes } from 'react';
33
import React from 'react';
4-
import Input from '../src';
5-
6-
const TextArea = Input.TextArea;
4+
import { TextArea } from '../src';
75

86
describe('should support allowClear', () => {
97
it('should change type when click', () => {

tests/TextArea.count.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { fireEvent, render } from '@testing-library/react';
22
import React from 'react';
3-
import Input from '../src';
4-
5-
const TextArea = Input.TextArea;
3+
import { TextArea } from '../src';
64

75
const getSegments = (val: string) => [...new Intl.Segmenter().segment(val)];
86

tests/TextArea.focus.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// @ts-nocheck
22
import { fireEvent, render } from '@testing-library/react';
33
import React from 'react';
4-
import Input from '../src';
5-
import type { TextAreaRef } from '../src';
6-
7-
const TextArea = Input.TextArea;
4+
import { TextArea, type TextAreaRef } from '../src';
85

96
describe('focus and blur', () => {
107
let focused = false;

tests/TextArea.showCount.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { render } from '@testing-library/react';
22
import React from 'react';
3-
import Input from '../src';
4-
5-
const TextArea = Input.TextArea;
3+
import { TextArea } from '../src';
64

75
describe('should support showCount', () => {
86
it('maxLength', () => {

tests/TextArea.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
// @ts-nocheck
22
import { fireEvent, render } from '@testing-library/react';
33
import React from 'react';
4-
import Input from '../src';
5-
import type { TextAreaProps, TextAreaRef } from '../src';
4+
import { TextArea, type TextAreaProps, type TextAreaRef } from '../src';
65
import calculateAutoSizeStyle, {
76
calculateNodeStyling,
87
} from '../src/calculateNodeHeight';
98
import { triggerResize, wait } from './utils';
109

11-
const TextArea = Input.TextArea;
12-
1310
describe('TextArea', () => {
1411
const originalGetComputedStyle = window.getComputedStyle;
1512
beforeAll(() => {

0 commit comments

Comments
 (0)