@patternfly/react-core 4.235.5 → 4.235.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.235.5",
3
+ "version": "4.235.6",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,9 +44,9 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.86.5",
48
- "@patternfly/react-styles": "^4.85.5",
49
- "@patternfly/react-tokens": "^4.87.5",
47
+ "@patternfly/react-icons": "^4.86.6",
48
+ "@patternfly/react-styles": "^4.85.6",
49
+ "@patternfly/react-tokens": "^4.87.6",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8.0 || ^17.0.0",
71
71
  "react-dom": "^16.8.0 || ^17.0.0"
72
72
  },
73
- "gitHead": "6ec6b7c439ec2475f03ddfdc9ad494396aecb6a6"
73
+ "gitHead": "e688e3b26385dc09280dca250d72a733ce18b52a"
74
74
  }
@@ -129,6 +129,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
129
129
  </span>
130
130
  </Button>
131
131
  <TextInput
132
+ {...inputProps}
132
133
  type="number"
133
134
  value={value}
134
135
  name={inputName}
@@ -139,7 +140,6 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
139
140
  {...(!onChange && { isReadOnly: true })}
140
141
  onKeyDown={keyDownHandler}
141
142
  validated={validated}
142
- {...inputProps}
143
143
  />
144
144
  <Button
145
145
  variant="control"
@@ -10,19 +10,19 @@ describe('numberInput', () => {
10
10
  });
11
11
 
12
12
  test('renders success validated', () => {
13
- const { asFragment } = render(<NumberInput validated='success' />);
13
+ const { asFragment } = render(<NumberInput validated="success" />);
14
14
  expect(asFragment()).toMatchSnapshot();
15
- })
15
+ });
16
16
 
17
17
  test('renders error validated', () => {
18
- const { asFragment } = render(<NumberInput validated='error' />);
18
+ const { asFragment } = render(<NumberInput validated="error" />);
19
19
  expect(asFragment()).toMatchSnapshot();
20
- })
20
+ });
21
21
 
22
22
  test('renders warning validated', () => {
23
- const { asFragment } = render(<NumberInput validated='warning' />);
23
+ const { asFragment } = render(<NumberInput validated="warning" />);
24
24
  expect(asFragment()).toMatchSnapshot();
25
- })
25
+ });
26
26
 
27
27
  test('renders value', () => {
28
28
  const { asFragment } = render(<NumberInput value={90} />);
@@ -136,37 +136,37 @@ describe('numberInput', () => {
136
136
 
137
137
  test('removes leading zeros from a positive whole number', () => {
138
138
  render(<NumberInput value={10} onChange={() => {}} />);
139
-
139
+
140
140
  const input = screen.getByRole('spinbutton');
141
141
  userEvent.type(input, '{arrowleft}{arrowleft}0');
142
142
  expect(input).toHaveDisplayValue('010');
143
-
143
+
144
144
  userEvent.click(document.body);
145
-
145
+
146
146
  expect(input).toHaveDisplayValue('10');
147
147
  });
148
148
 
149
149
  test('removes leading zeros from a negative whole number', () => {
150
150
  render(<NumberInput value={-18} onChange={() => {}} />);
151
-
151
+
152
152
  const input = screen.getByRole('spinbutton');
153
153
  userEvent.type(input, '{arrowleft}{arrowleft}0');
154
154
  expect(input).toHaveDisplayValue('-018');
155
-
155
+
156
156
  userEvent.click(document.body);
157
-
157
+
158
158
  expect(input).toHaveDisplayValue('-18');
159
159
  });
160
160
 
161
161
  test('removes leading zeros from a decimal number', () => {
162
162
  render(<NumberInput value={47.01} onChange={() => {}} />);
163
-
163
+
164
164
  const input = screen.getByRole('spinbutton');
165
165
  userEvent.type(input, '{arrowleft}{arrowleft}{arrowleft}{arrowleft}{arrowleft}0');
166
166
  expect(input).toHaveDisplayValue('047.01');
167
-
167
+
168
168
  userEvent.click(document.body);
169
-
169
+
170
170
  expect(input).toHaveDisplayValue('47.01');
171
171
  });
172
172
 
@@ -187,4 +187,23 @@ describe('numberInput', () => {
187
187
  const input = screen.getByRole('spinbutton');
188
188
  expect(input).toHaveDisplayValue('0');
189
189
  });
190
+
191
+ test('does not throw an error if onChange is passed via inputProps as well as the onChange prop', () => {
192
+ const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
193
+
194
+ const NumberInputWrapper = () => {
195
+ const [value, setValue] = React.useState(0);
196
+ const onChange = event => setValue(event.currentTarget.value);
197
+ const inputProps = { onChange: onChange };
198
+
199
+ return <NumberInput value={value} onChange={onChange} inputProps={{ ...inputProps }} />;
200
+ };
201
+
202
+ render(<NumberInputWrapper />);
203
+
204
+ const input = screen.getByRole('spinbutton');
205
+ userEvent.type(input, '0');
206
+
207
+ expect(consoleSpy).not.toHaveBeenCalled();
208
+ });
190
209
  });