Skip to content

Commit d502980

Browse files
feat(date-time-picker-web): implement onChange handling in DatePickerController
1 parent 76ac101 commit d502980

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/pluggableWidgets/date-time-picker-web/src/components/DateTimePickerContainer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export function DateTimePickerContainer(props: DateTimePickerContainerProps) {
1515
const label = props.showLabel && props.label?.status === "available" ? props.label.value : null;
1616
const portalId = `datepicker_` + Math.random();
1717

18-
console.info("Rendering DateTimePicker", label, pickerProps);
19-
2018
// still have to add validation for max and min time and validation message
2119
console.info("unused props", {
2220
name: props.name,

packages/pluggableWidgets/date-time-picker-web/src/helpers/DatePickerController.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ export class DatePickerController {
2424
private _timer = -1;
2525
private _defaultState: Array<Date | undefined>;
2626
private _type: "date" | "time" | "datetime" | "range";
27+
private _onChange?: ActionValue<"none">;
2728
expanded = false;
2829
pickerRef = createRef<DatePicker>();
2930

3031
constructor(params: Params) {
3132
this._dates = this.getDefaults(params);
3233
this._defaultState = this.getDefaults(params);
3334
this._type = params.type;
34-
35-
// implement onChange action
35+
this._onChange = params.onChange;
3636

3737
makeObservable(this, {
3838
pickerState: computed,
@@ -63,9 +63,13 @@ export class DatePickerController {
6363
const [start, end] = value as [Date | null, Date | null];
6464
this._dates[0] = start ?? undefined;
6565
this._dates[1] = end ?? undefined;
66+
67+
this._onChange?.canExecute && !this._onChange.isExecuting && this._onChange.execute();
6668
return;
6769
} else {
6870
this._dates[0] = value as Date;
71+
72+
this._onChange?.canExecute && !this._onChange.isExecuting && this._onChange.execute();
6973
return;
7074
}
7175
};

0 commit comments

Comments
 (0)