Skip to content

Commit 563a73a

Browse files
author
Sasha Kondrashov
committed
textarea
1 parent f14c5fd commit 563a73a

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/addons/TextArea/TextArea.d.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@ export interface StrictTextAreaProps {
1313
* Called on change.
1414
*
1515
* @param {SyntheticEvent} event - The React SyntheticEvent object
16-
* @param {object} data - All props and the event value.
16+
* @param {object} props - All props.
17+
* @param {string} value - The value of the textarea.
1718
*/
18-
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, data: TextAreaProps) => void
19+
onChange?: (
20+
event: React.ChangeEvent<HTMLTextAreaElement>,
21+
props: TextAreaProps,
22+
value: string,
23+
) => void
1924

2025
/**
2126
* Called on input.
2227
*
2328
* @param {SyntheticEvent} event - The React SyntheticEvent object
24-
* @param {object} data - All props and the event value.
29+
* @param {object} props - All props.
30+
* @param {string} value - The value of the textarea.
2531
*/
26-
onInput?: (event: React.FormEvent<HTMLTextAreaElement>, data: TextAreaProps) => void
32+
onInput?: (
33+
event: React.FormEvent<HTMLTextAreaElement>,
34+
props: TextAreaProps,
35+
value: string,
36+
) => void
2737

2838
/** Indicates row count for a TextArea. */
2939
rows?: number | string

src/addons/TextArea/TextArea.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ const TextArea = React.forwardRef(function (props, ref) {
1515
const handleChange = (e) => {
1616
const newValue = _.get(e, 'target.value')
1717

18-
_.invoke(props, 'onChange', e, { ...props, value: newValue })
18+
_.invoke(props, 'onChange', e, props, newValue)
1919
}
2020

2121
const handleInput = (e) => {
2222
const newValue = _.get(e, 'target.value')
2323

24-
_.invoke(props, 'onInput', e, { ...props, value: newValue })
24+
_.invoke(props, 'onInput', e, props, newValue)
2525
}
2626

2727
const rest = getUnhandledProps(TextArea, props)

test/specs/addons/TextArea/TextArea-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('TextArea', () => {
5050
})
5151

5252
describe('onChange', () => {
53-
it('is called with (e, data) on change', () => {
53+
it('is called with (e, props, value) on change', () => {
5454
const onChange = sandbox.spy()
5555
const e = { target: { value: 'name' } }
5656
const props = { 'data-foo': 'bar', onChange }
@@ -59,12 +59,12 @@ describe('TextArea', () => {
5959
wrapper.find('textarea').simulate('change', e)
6060

6161
onChange.should.have.been.calledOnce()
62-
onChange.should.have.been.calledWithMatch(e, { ...props, value: e.target.value })
62+
onChange.should.have.been.calledWithMatch(e, props, e.target.value)
6363
})
6464
})
6565

6666
describe('onInput', () => {
67-
it('is called with (e, data) on input', () => {
67+
it('is called with (e, props, value) on input', () => {
6868
const onInput = sandbox.spy()
6969
const e = { target: { value: 'name' } }
7070
const props = { 'data-foo': 'bar', onInput }
@@ -73,7 +73,7 @@ describe('TextArea', () => {
7373
wrapper.find('textarea').simulate('input', e)
7474

7575
onInput.should.have.been.calledOnce()
76-
onInput.should.have.been.calledWithMatch(e, { ...props, value: e.target.value })
76+
onInput.should.have.been.calledWithMatch(e, props, e.target.value)
7777
})
7878
})
7979

0 commit comments

Comments
 (0)