@patternfly/react-core 4.276.7 → 4.276.9

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.276.7",
3
+ "version": "4.276.9",
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",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@patternfly/react-icons": "^4.93.6",
49
- "@patternfly/react-styles": "^4.92.6",
49
+ "@patternfly/react-styles": "^4.92.7",
50
50
  "@patternfly/react-tokens": "^4.94.6",
51
51
  "focus-trap": "6.9.2",
52
52
  "react-dropzone": "9.0.0",
@@ -71,5 +71,5 @@
71
71
  "react": "^16.8 || ^17 || ^18",
72
72
  "react-dom": "^16.8 || ^17 || ^18"
73
73
  },
74
- "gitHead": "29d829b6a774e4cd162b0551c02792b3113e5f1b"
74
+ "gitHead": "fe114d6d5b6d072d2dcfc595bdf8a5836668f924"
75
75
  }
@@ -376,9 +376,22 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
376
376
  onToggle = (isOpen: boolean) => {
377
377
  // on close, parse and validate input
378
378
  this.setState(prevState => {
379
- const { timeRegex, isInvalid } = prevState;
380
- const { delimiter, is24Hour, includeSeconds } = this.props;
381
- const time = parseTime(prevState.timeState, timeRegex, delimiter, !is24Hour, includeSeconds);
379
+ const { timeRegex, isInvalid, timeState } = prevState;
380
+ const { delimiter, is24Hour, includeSeconds, onChange } = this.props;
381
+ const time = parseTime(timeState, timeRegex, delimiter, !is24Hour, includeSeconds);
382
+
383
+ // Call onChange when Enter is pressed in input and timeoption does not exist in menu
384
+ if (onChange && !isOpen && time !== timeState) {
385
+ onChange(
386
+ null,
387
+ time,
388
+ getHours(time, timeRegex),
389
+ getMinutes(time, timeRegex),
390
+ getSeconds(time, timeRegex),
391
+ this.isValid(time)
392
+ );
393
+ }
394
+
382
395
  return {
383
396
  isTimeOptionsOpen: isOpen,
384
397
  timeState: time,
@@ -417,7 +430,6 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
417
430
  onInputChange = (newTime: string, event: React.FormEvent<HTMLInputElement>) => {
418
431
  const { onChange } = this.props;
419
432
  const { timeRegex } = this.state;
420
-
421
433
  if (onChange) {
422
434
  onChange(
423
435
  event,
@@ -86,6 +86,27 @@ describe('TimePicker', () => {
86
86
  expects: { hour: 23, minutes: 59, seconds: null }
87
87
  });
88
88
  });
89
+
90
+ test('should call onChange when pressing Enter', async () => {
91
+ const onChange = jest.fn();
92
+ const user = userEvent.setup();
93
+
94
+ render(<TimePicker onChange={onChange} aria-label="time picker" />);
95
+
96
+ // Take into account timezones when tests are ran
97
+ const isPM = new Date().getHours() > 12;
98
+
99
+ await user.type(screen.getByLabelText('time picker'), `11:11`);
100
+ await user.keyboard('[Enter]');
101
+ expect(onChange).toHaveBeenLastCalledWith(
102
+ expect.any(Object),
103
+ `11:11 ${isPM ? 'PM' : 'AM'}`,
104
+ isPM ? 23 : 11,
105
+ 11,
106
+ null,
107
+ true
108
+ );
109
+ });
89
110
  });
90
111
 
91
112
  describe('test isInvalid', () => {