Skip to content

Commit

Permalink
Merge branch 'main' into color-tokens-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Apr 26, 2021
2 parents c3fedfa + 19cd709 commit e9d9182
Show file tree
Hide file tree
Showing 34 changed files with 125 additions and 156 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
],
"dependencies": {
"@babel/preset-env": "^7.12.13",
"jscodeshift": "^0.11.0"
"jscodeshift": "^0.12.0"
}
}
10 changes: 7 additions & 3 deletions packages/react/src/components/NumberInput/NumberInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,10 @@ describe('NumberInput', () => {
});

it('should invoke onClick when up arrow is clicked', () => {
wrapper.setProps({ value: 1 });
upArrow.simulate('click');
expect(onClick).toBeCalled();
expect(onClick).toHaveBeenCalledWith(expect.anything(), 'up');
expect(onClick).toHaveBeenCalledWith(expect.anything(), 'up', 2);
});

it('should only increase the value on up arrow click if value is less than max', () => {
Expand Down Expand Up @@ -466,13 +467,16 @@ describe('NumberInput', () => {
downArrow.simulate('click');
expect(onClick).toBeCalled();
expect(onChange).toBeCalled();
expect(onClick).toHaveBeenCalledWith(expect.anything(), 'down');
expect(onClick).toHaveBeenCalledWith(expect.anything(), 'down', 0);
});

it('should invoke onChange when numberInput is changed', () => {
input.simulate('change');
expect(onChange).toBeCalled();
expect(onChange).toHaveBeenCalledWith(expect.anything());
expect(onChange).toHaveBeenCalledWith(
expect.anything(),
expect.anything()
);
});
});
});
Expand Down
12 changes: 8 additions & 4 deletions packages/react/src/components/NumberInput/NumberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,18 @@ class NumberInput extends Component {
if (!disabled) {
evt.persist();
evt.imaginaryTarget = this._inputRef;
const prevValue = this.state.value;
const value = evt.target.value;
const direction = prevValue < value ? 'up' : 'down';
this.setState(
{
value,
},
() => {
if (useControlledStateWithValue) {
onChange(evt, { value });
onChange(evt, { value, direction });
} else if (onChange) {
onChange(evt);
onChange(evt, { value, direction });
}
}
);
Expand Down Expand Up @@ -286,12 +288,14 @@ class NumberInput extends Component {
value,
},
() => {
//TO-DO v11: update these events to return the same things --> evt, {value, direction}
if (useControlledStateWithValue) {
onClick && onClick(evt, { value, direction });
onChange && onChange(evt, { value, direction });
} else {
onClick && onClick(evt, direction);
onChange && onChange(evt, direction);
// value added as a 3rd argument rather than in same obj so it doesn't break in v10
onClick && onClick(evt, direction, value);
onChange && onChange(evt, direction, value);
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion packages/upgrade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"fs-extra": "^8.1.0",
"inquirer": "^6.3.1",
"jest-diff": "^23.6.0",
"jscodeshift": "^0.6.4",
"jscodeshift": "^0.12.0",
"lodash.clonedeep": "^4.5.0",
"npm-which": "^3.0.1",
"semver": "^7.3.4",
Expand Down
Loading

0 comments on commit e9d9182

Please sign in to comment.