@instructure/ui-date-time-input 8.46.2-snapshot-2 → 8.46.2-snapshot-4

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/CHANGELOG.md CHANGED
@@ -3,9 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.46.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v8.46.1...v8.46.2-snapshot-2) (2023-10-17)
6
+ ## [8.46.2-snapshot-4](https://github.com/instructure/instructure-ui/compare/v8.46.1...v8.46.2-snapshot-4) (2023-10-18)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-date-time-input
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-date-time-input:** clear TimeSelect value when DateInput value is cleared ([b1a58e5](https://github.com/instructure/instructure-ui/commit/b1a58e5c04822da491966bc0a79403b30749ff7e))
9
12
 
10
13
 
11
14
 
@@ -89,7 +89,7 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeI
89
89
  });
90
90
  }, 0);
91
91
  };
92
- this.handleTimeChange = (event, option) => {
92
+ this.updateStateBasedOnTimeSelect = (event, option) => {
93
93
  // this.state.iso is undefined if date is invalid or not set.
94
94
  // in this case recalculate with the dateInput's text which will result in
95
95
  // an empty valid date (if isRequired is false) or an invalid date.
@@ -252,12 +252,21 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeI
252
252
  };
253
253
  }
254
254
  }
255
+ // if there is no date string clear TimeSelect value
256
+ const clearTimeSelect = dateStr ? {} : {
257
+ timeSelectValue: '',
258
+ message: {
259
+ type: 'success',
260
+ text: ''
261
+ }
262
+ };
255
263
  return {
256
264
  iso: void 0,
257
265
  calendarSelectedDate: void 0,
258
266
  dateInputText: dateStr ? dateStr : '',
259
267
  renderedDate: DateTime.now(this.locale(), this.timezone()),
260
- dateInputTextChanged: false
268
+ dateInputTextChanged: false,
269
+ ...clearTimeSelect
261
270
  };
262
271
  }
263
272
  locale() {
@@ -447,7 +456,7 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeI
447
456
  renderNavigationLabel: /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("div", null, this.state.renderedDate.format('MMMM')), /*#__PURE__*/React.createElement("div", null, this.state.renderedDate.format('y')))
448
457
  }, this.renderDays()), /*#__PURE__*/React.createElement(TimeSelect, {
449
458
  value: this.state.timeSelectValue,
450
- onChange: this.handleTimeChange,
459
+ onChange: this.updateStateBasedOnTimeSelect,
451
460
  onBlur: this.handleBlur,
452
461
  renderLabel: timeRenderLabel,
453
462
  locale: locale,
@@ -97,7 +97,7 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 =
97
97
  });
98
98
  }, 0);
99
99
  };
100
- this.handleTimeChange = (event, option) => {
100
+ this.updateStateBasedOnTimeSelect = (event, option) => {
101
101
  // this.state.iso is undefined if date is invalid or not set.
102
102
  // in this case recalculate with the dateInput's text which will result in
103
103
  // an empty valid date (if isRequired is false) or an invalid date.
@@ -260,12 +260,21 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 =
260
260
  };
261
261
  }
262
262
  }
263
+ // if there is no date string clear TimeSelect value
264
+ const clearTimeSelect = dateStr ? {} : {
265
+ timeSelectValue: '',
266
+ message: {
267
+ type: 'success',
268
+ text: ''
269
+ }
270
+ };
263
271
  return {
264
272
  iso: void 0,
265
273
  calendarSelectedDate: void 0,
266
274
  dateInputText: dateStr ? dateStr : '',
267
275
  renderedDate: _DateTime.DateTime.now(this.locale(), this.timezone()),
268
- dateInputTextChanged: false
276
+ dateInputTextChanged: false,
277
+ ...clearTimeSelect
269
278
  };
270
279
  }
271
280
  locale() {
@@ -455,7 +464,7 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 =
455
464
  renderNavigationLabel: /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("div", null, this.state.renderedDate.format('MMMM')), /*#__PURE__*/_react.default.createElement("div", null, this.state.renderedDate.format('y')))
456
465
  }, this.renderDays()), /*#__PURE__*/_react.default.createElement(_TimeSelect.TimeSelect, {
457
466
  value: this.state.timeSelectValue,
458
- onChange: this.handleTimeChange,
467
+ onChange: this.updateStateBasedOnTimeSelect,
459
468
  onBlur: this.handleBlur,
460
469
  renderLabel: timeRenderLabel,
461
470
  locale: locale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-time-input",
3
- "version": "8.46.2-snapshot-2",
3
+ "version": "8.46.2-snapshot-4",
4
4
  "description": "A UI component that allows to select date and time.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,26 +23,26 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.46.2-snapshot-2",
27
- "@instructure/ui-test-locator": "8.46.2-snapshot-2",
28
- "@instructure/ui-test-utils": "8.46.2-snapshot-2"
26
+ "@instructure/ui-babel-preset": "8.46.2-snapshot-4",
27
+ "@instructure/ui-test-locator": "8.46.2-snapshot-4",
28
+ "@instructure/ui-test-utils": "8.46.2-snapshot-4"
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.22.15",
32
- "@instructure/debounce": "8.46.2-snapshot-2",
33
- "@instructure/emotion": "8.46.2-snapshot-2",
34
- "@instructure/ui-a11y-content": "8.46.2-snapshot-2",
35
- "@instructure/ui-buttons": "8.46.2-snapshot-2",
36
- "@instructure/ui-calendar": "8.46.2-snapshot-2",
37
- "@instructure/ui-date-input": "8.46.2-snapshot-2",
38
- "@instructure/ui-form-field": "8.46.2-snapshot-2",
39
- "@instructure/ui-i18n": "8.46.2-snapshot-2",
40
- "@instructure/ui-icons": "8.46.2-snapshot-2",
41
- "@instructure/ui-prop-types": "8.46.2-snapshot-2",
42
- "@instructure/ui-react-utils": "8.46.2-snapshot-2",
43
- "@instructure/ui-testable": "8.46.2-snapshot-2",
44
- "@instructure/ui-time-select": "8.46.2-snapshot-2",
45
- "@instructure/ui-utils": "8.46.2-snapshot-2",
32
+ "@instructure/debounce": "8.46.2-snapshot-4",
33
+ "@instructure/emotion": "8.46.2-snapshot-4",
34
+ "@instructure/ui-a11y-content": "8.46.2-snapshot-4",
35
+ "@instructure/ui-buttons": "8.46.2-snapshot-4",
36
+ "@instructure/ui-calendar": "8.46.2-snapshot-4",
37
+ "@instructure/ui-date-input": "8.46.2-snapshot-4",
38
+ "@instructure/ui-form-field": "8.46.2-snapshot-4",
39
+ "@instructure/ui-i18n": "8.46.2-snapshot-4",
40
+ "@instructure/ui-icons": "8.46.2-snapshot-4",
41
+ "@instructure/ui-prop-types": "8.46.2-snapshot-4",
42
+ "@instructure/ui-react-utils": "8.46.2-snapshot-4",
43
+ "@instructure/ui-testable": "8.46.2-snapshot-4",
44
+ "@instructure/ui-time-select": "8.46.2-snapshot-4",
45
+ "@instructure/ui-utils": "8.46.2-snapshot-4",
46
46
  "prop-types": "^15.8.1"
47
47
  },
48
48
  "peerDependencies": {
@@ -68,7 +68,7 @@ class Example extends React.Component {
68
68
  let messages = []
69
69
  if (!isoDate) {
70
70
  // this happens if an invalid date is entered
71
- this.setState({ messages })
71
+ this.setState({ messages:messages, value:undefined })
72
72
  return
73
73
  }
74
74
  const now = new Date()
@@ -171,12 +171,23 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
171
171
  }
172
172
  }
173
173
  }
174
+ // if there is no date string clear TimeSelect value
175
+ const clearTimeSelect: Partial<DateTimeInputState> = dateStr
176
+ ? {}
177
+ : {
178
+ timeSelectValue: '',
179
+ message: {
180
+ type: 'success',
181
+ text: ''
182
+ }
183
+ }
174
184
  return {
175
185
  iso: undefined,
176
186
  calendarSelectedDate: undefined,
177
187
  dateInputText: dateStr ? dateStr : '',
178
188
  renderedDate: DateTime.now(this.locale(), this.timezone()),
179
- dateInputTextChanged: false
189
+ dateInputTextChanged: false,
190
+ ...clearTimeSelect
180
191
  }
181
192
  }
182
193
 
@@ -295,7 +306,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
295
306
  this.changeStateIfNeeded(newState, event)
296
307
  }
297
308
 
298
- handleTimeChange = (
309
+ updateStateBasedOnTimeSelect = (
299
310
  event: SyntheticEvent,
300
311
  option: { value?: string; inputText: string }
301
312
  ) => {
@@ -566,7 +577,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
566
577
  </DateInput>
567
578
  <TimeSelect
568
579
  value={this.state.timeSelectValue}
569
- onChange={this.handleTimeChange}
580
+ onChange={this.updateStateBasedOnTimeSelect}
570
581
  onBlur={this.handleBlur}
571
582
  renderLabel={timeRenderLabel}
572
583
  locale={locale}