Skip to content

Commit 7bbc6c6

Browse files
authored
fix(time-input): call onChange with generated id instead of undefined if no id passed as prop (#427)
1 parent 4af37ed commit 7bbc6c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/components/inputs/time-input/time-input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class TimeInput extends React.Component {
8282

8383
emitChange = value => {
8484
const event = {
85-
target: { id: this.props.id, name: this.props.name, value },
85+
target: { id: this.state.id, name: this.props.name, value },
8686
};
8787
this.props.onChange(event);
8888
};

src/components/inputs/time-input/time-input.spec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ describe('TimeInput', () => {
119119
container.querySelector('input').blur();
120120
expect(container.querySelector('input')).not.toHaveFocus();
121121
expect(onChange).toHaveBeenCalledWith({
122-
target: { id: undefined, name: undefined, value: '2:03 AM' },
122+
target: {
123+
id: expect.stringMatching(/^time-input-/i),
124+
name: undefined,
125+
value: '2:03 AM',
126+
},
123127
});
124128
});
125129

@@ -136,7 +140,7 @@ describe('TimeInput', () => {
136140
expect(container.querySelector('input')).not.toHaveFocus();
137141
expect(onChange).toHaveBeenCalledWith({
138142
target: {
139-
id: undefined,
143+
id: expect.stringMatching(/^time-input-/i),
140144
name: undefined,
141145
// There is a limitation in node where the underlying Intl API used by
142146
// react-intl does not contain the full locale data and falls back to

0 commit comments

Comments
 (0)