Skip to content

Commit 06a34bc

Browse files
Scheduler - Fix appointment form state between popup openings
1 parent 312da62 commit 06a34bc

6 files changed

Lines changed: 29 additions & 11 deletions

File tree

apps/demos/Demos/Scheduler/ResolveTimeConflicts/Angular/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class AppComponent {
6262
onInitialized: (e: DxPopupTypes.InitializedEvent) => { this.popup = e.component; },
6363
onHidden: () => {
6464
this.setConflictError(false);
65-
this.form?.updateData('assigneeId', []);
6665
},
6766
};
6867

apps/demos/Demos/Scheduler/ResolveTimeConflicts/React/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ const App = () => {
157157
},
158158
onHidden: () => {
159159
setConflictError(false);
160-
formRef.current?.updateData('assigneeId', []);
161160
},
162161
}), [setConflictError]);
163162

apps/demos/Demos/Scheduler/ResolveTimeConflicts/Vue/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ const popupOptions = {
186186
},
187187
onHidden: () => {
188188
setConflictError(false);
189-
form?.updateData('assigneeId', []);
190189
},
191190
};
192191

apps/demos/Demos/Scheduler/ResolveTimeConflicts/jQuery/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ $(() => {
2929
},
3030
onHidden: () => {
3131
setConflictError(false);
32-
form?.updateData('assigneeId', []);
3332
},
3433
},
3534
form: {

packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,20 @@ describe('Appointment Form', () => {
441441
expect(POM.popup.getInputValue('roomId')).toBe('');
442442
});
443443

444+
it('should create a new form instance on each popup opening', async () => {
445+
const { scheduler, POM } = await createScheduler(getDefaultConfig());
446+
447+
scheduler.showAppointmentPopup(commonAppointment);
448+
const firstFormInstance = POM.popup.dxForm;
449+
450+
POM.popup.cancelButton.click();
451+
452+
scheduler.showAppointmentPopup(commonAppointment);
453+
const secondFormInstance = POM.popup.dxForm;
454+
455+
expect(secondFormInstance).not.toBe(firstFormInstance);
456+
});
457+
444458
it('should have correct repeat editor value when opening recurring appointment after common appointment', async () => {
445459
const { scheduler, POM } = await createScheduler(getDefaultConfig());
446460

packages/devextreme/js/__internal/scheduler/appointment_popup/m_popup.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ export class AppointmentPopup {
6969
this.state.allowSaving = config.allowSaving;
7070
this.state.excludeInfo = config.excludeInfo;
7171

72-
if (!this._popup) {
73-
const popupConfig = this._createPopupConfig();
74-
this._createPopup(popupConfig);
75-
}
72+
this._disposePopup();
73+
74+
const popupConfig = this._createPopupConfig();
75+
this._createPopup(popupConfig);
7676

7777
this._popup!.show();
7878
}
@@ -82,9 +82,17 @@ export class AppointmentPopup {
8282
}
8383

8484
dispose() {
85-
this.form.dispose();
86-
this._popup?.dispose();
87-
this._popup = undefined;
85+
this._disposePopup();
86+
}
87+
88+
private _disposePopup(): void {
89+
if (this._popup) {
90+
const $element = this._popup.$element();
91+
this.form.dispose();
92+
this._popup.dispose();
93+
$element.remove();
94+
this._popup = undefined;
95+
}
8896
}
8997

9098
_createPopup(options): void {

0 commit comments

Comments
 (0)