Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(time-input): call onChange with generated ID if none passed #427

Merged
merged 1 commit into from
Jan 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(time-input): call onChange with generated id instead of undefined…
… if no id passed as prop
montezume committed Jan 11, 2019

Unverified

This user has not yet uploaded their public signing key.
commit e38d3af0eecadc98036c93edbc5d54e78cac65ee
2 changes: 1 addition & 1 deletion src/components/inputs/time-input/time-input.js
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ export class TimeInput extends React.Component {

emitChange = value => {
const event = {
target: { id: this.props.id, name: this.props.name, value },
target: { id: this.state.id, name: this.props.name, value },
};
this.props.onChange(event);
};
8 changes: 6 additions & 2 deletions src/components/inputs/time-input/time-input.spec.js
Original file line number Diff line number Diff line change
@@ -119,7 +119,11 @@ describe('TimeInput', () => {
container.querySelector('input').blur();
expect(container.querySelector('input')).not.toHaveFocus();
expect(onChange).toHaveBeenCalledWith({
target: { id: undefined, name: undefined, value: '2:03 AM' },
target: {
id: expect.stringMatching(/^time-input-/i),
name: undefined,
value: '2:03 AM',
},
});
});

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