Skip to content

Commit 906206d

Browse files
xinpingwangkilya11
andauthored
Pass title prop to input (react-component#218)
* Type for the title prop react-component#104 * Pass title prop react-component#104 * Test title prop react-component#104 * Remove trailing spaces Co-authored-by: kilya11 <[email protected]>
1 parent 98751ea commit 906206d

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Props {
77
name?: string;
88
id?: string;
99
type?: string;
10+
title?: string;
1011
defaultChecked?: number | boolean;
1112
checked?: number | boolean;
1213
disabled?: boolean;

src/index.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Checkbox extends Component {
88
className: '',
99
style: {},
1010
type: 'checkbox',
11+
title: '',
1112
defaultChecked: false,
1213
onFocus() {},
1314
onBlur() {},
@@ -84,6 +85,7 @@ class Checkbox extends Component {
8485
name,
8586
id,
8687
type,
88+
title,
8789
disabled,
8890
readOnly,
8991
tabIndex,
@@ -119,6 +121,7 @@ class Checkbox extends Component {
119121
name={name}
120122
id={id}
121123
type={type}
124+
title={title}
122125
required={required}
123126
readOnly={readOnly}
124127
disabled={disabled}

tests/index.test.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ describe('rc-checkbox', () => {
7777
expect(renderedInput.attributes.value.value).toEqual('6');
7878
});
7979

80+
it('passes title prop to input', () => {
81+
const wrapper = mount(<Checkbox title="my-custom-title" />);
82+
const renderedInput = wrapper.find('input').instance();
83+
expect(renderedInput.attributes.title.value).toEqual('my-custom-title');
84+
});
85+
8086
it('focus()', () => {
8187
const container = document.createElement('div');
8288
document.body.appendChild(container);

0 commit comments

Comments
 (0)