@instructure/ui-date-time-input 10.9.0 → 10.9.1-pr-snapshot-1734382183600

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,6 +3,17 @@
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
+ ## [10.9.1-pr-snapshot-1734382183600](https://github.com/instructure/instructure-ui/compare/v10.9.0...v10.9.1-pr-snapshot-1734382183600) (2024-12-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-date-time-input:** fix DateTimeInput displaying wrong value of its value is changed in a onChange callback ([c4be5d3](https://github.com/instructure/instructure-ui/commit/c4be5d3f96de8fe9b2e562677737bc567cce9fa8))
12
+
13
+
14
+
15
+
16
+
6
17
  # [10.9.0](https://github.com/instructure/instructure-ui/compare/v10.8.0...v10.9.0) (2024-12-12)
7
18
 
8
19
  **Note:** Version bump only for package @instructure/ui-date-time-input
@@ -112,8 +112,16 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class Da
112
112
  };
113
113
  }
114
114
  if (this.areDifferentDates(this.state.iso, newState.iso)) {
115
- var _this$props$onChange, _this$props, _newState$iso;
116
- (_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e, (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString());
115
+ if (typeof this.props.onChange === 'function') {
116
+ var _newState$iso;
117
+ const newDate = (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString();
118
+ // Timeout is needed here because users might change value in the
119
+ // onChange event lister, which might not execute properly
120
+ window.setTimeout(() => {
121
+ var _this$props$onChange, _this$props;
122
+ (_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e, newDate);
123
+ }, 0);
124
+ }
117
125
  }
118
126
  this.setState(newState);
119
127
  };
@@ -120,8 +120,16 @@ let DateTimeInput = exports.DateTimeInput = (_dec = (0, _testable.testable)(), _
120
120
  };
121
121
  }
122
122
  if (this.areDifferentDates(this.state.iso, newState.iso)) {
123
- var _this$props$onChange, _this$props, _newState$iso;
124
- (_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e, (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString());
123
+ if (typeof this.props.onChange === 'function') {
124
+ var _newState$iso;
125
+ const newDate = (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString();
126
+ // Timeout is needed here because users might change value in the
127
+ // onChange event lister, which might not execute properly
128
+ window.setTimeout(() => {
129
+ var _this$props$onChange, _this$props;
130
+ (_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e, newDate);
131
+ }, 0);
132
+ }
125
133
  }
126
134
  this.setState(newState);
127
135
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-time-input",
3
- "version": "10.9.0",
3
+ "version": "10.9.1-pr-snapshot-1734382183600",
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,8 +23,8 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "10.9.0",
27
- "@instructure/ui-test-utils": "10.9.0",
26
+ "@instructure/ui-babel-preset": "10.9.1-pr-snapshot-1734382183600",
27
+ "@instructure/ui-test-utils": "10.9.1-pr-snapshot-1734382183600",
28
28
  "@testing-library/jest-dom": "^6.6.3",
29
29
  "@testing-library/react": "^16.0.1",
30
30
  "@testing-library/user-event": "^14.5.2",
@@ -32,20 +32,20 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.26.0",
35
- "@instructure/console": "10.9.0",
36
- "@instructure/shared-types": "10.9.0",
37
- "@instructure/ui-a11y-content": "10.9.0",
38
- "@instructure/ui-buttons": "10.9.0",
39
- "@instructure/ui-calendar": "10.9.0",
40
- "@instructure/ui-date-input": "10.9.0",
41
- "@instructure/ui-form-field": "10.9.0",
42
- "@instructure/ui-i18n": "10.9.0",
43
- "@instructure/ui-icons": "10.9.0",
44
- "@instructure/ui-prop-types": "10.9.0",
45
- "@instructure/ui-react-utils": "10.9.0",
46
- "@instructure/ui-testable": "10.9.0",
47
- "@instructure/ui-time-select": "10.9.0",
48
- "@instructure/ui-utils": "10.9.0",
35
+ "@instructure/console": "10.9.1-pr-snapshot-1734382183600",
36
+ "@instructure/shared-types": "10.9.1-pr-snapshot-1734382183600",
37
+ "@instructure/ui-a11y-content": "10.9.1-pr-snapshot-1734382183600",
38
+ "@instructure/ui-buttons": "10.9.1-pr-snapshot-1734382183600",
39
+ "@instructure/ui-calendar": "10.9.1-pr-snapshot-1734382183600",
40
+ "@instructure/ui-date-input": "10.9.1-pr-snapshot-1734382183600",
41
+ "@instructure/ui-form-field": "10.9.1-pr-snapshot-1734382183600",
42
+ "@instructure/ui-i18n": "10.9.1-pr-snapshot-1734382183600",
43
+ "@instructure/ui-icons": "10.9.1-pr-snapshot-1734382183600",
44
+ "@instructure/ui-prop-types": "10.9.1-pr-snapshot-1734382183600",
45
+ "@instructure/ui-react-utils": "10.9.1-pr-snapshot-1734382183600",
46
+ "@instructure/ui-testable": "10.9.1-pr-snapshot-1734382183600",
47
+ "@instructure/ui-time-select": "10.9.1-pr-snapshot-1734382183600",
48
+ "@instructure/ui-utils": "10.9.1-pr-snapshot-1734382183600",
49
49
  "prop-types": "^15.8.1"
50
50
  },
51
51
  "peerDependencies": {
@@ -351,7 +351,14 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
351
351
  newState.message = { text: text, type: 'error' }
352
352
  }
353
353
  if (this.areDifferentDates(this.state.iso, newState.iso)) {
354
- this.props.onChange?.(e, newState.iso?.toISOString())
354
+ if (typeof this.props.onChange === 'function') {
355
+ const newDate = newState.iso?.toISOString()
356
+ // Timeout is needed here because users might change value in the
357
+ // onChange event lister, which might not execute properly
358
+ window.setTimeout(() => {
359
+ this.props.onChange?.(e, newDate)
360
+ }, 0)
361
+ }
355
362
  }
356
363
  this.setState(newState)
357
364
  }
@@ -439,12 +446,12 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
439
446
  // Please note that this causes one hour of time difference in the affected timezones/dates and to
440
447
  // fully solve this bug we need to change to something like luxon which handles this properly
441
448
  if (currDate.clone().format('HH') === '23') {
442
- arr.push(currDate.clone().add({hours: 1}))
449
+ arr.push(currDate.clone().add({ hours: 1 }))
443
450
  } else {
444
451
  arr.push(currDate.clone())
445
452
  }
446
453
 
447
- currDate.add({days: 1})
454
+ currDate.add({ days: 1 })
448
455
  }
449
456
  return arr.map((date) => {
450
457
  const dateStr = date.toISOString()