Skip to content

Commit 29eb8c3

Browse files
authored
Scheduler - Appointment Form - Fix popup jump on group switching (#32944)
Signed-off-by: Eldar Iusupzhanov <84278206+Tucchhaa@users.noreply.github.com>
1 parent d9d41ce commit 29eb8c3

3 files changed

Lines changed: 83 additions & 6 deletions

File tree

  • e2e/testcafe-devextreme/tests/scheduler/common/appointmentForm
  • packages
    • devextreme/js/__internal/scheduler/appointment_popup
    • testcafe-models/scheduler

e2e/testcafe-devextreme/tests/scheduler/common/appointmentForm/form.functional.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ fixture.disablePageReloads`Appointment Form: Functional`
77

88
const SCHEDULER_SELECTOR = '#container';
99

10+
const roughEqualClientBoundingRect = (a: TextRectangle, b: TextRectangle): boolean => (
11+
Math.abs(a.width - b.width) < 1
12+
&& Math.abs(a.height - b.height) < 1
13+
&& Math.abs(a.top - b.top) < 1
14+
&& Math.abs(a.left - b.left) < 1
15+
);
16+
1017
test('Subject text editor should have focus after returning from recurrence form', async (t) => {
1118
const appointment = {
1219
text: 'Appointment',
@@ -60,3 +67,73 @@ test('Recurrence start date editor should have focus after opening recurrence se
6067
currentDate: new Date(2021, 2, 25),
6168
});
6269
});
70+
71+
test('Popup should not change dimensions when switching groups and recurrence group height is larger', async (t) => {
72+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
73+
74+
await scheduler.openAppointmentPopup(t);
75+
const boundingClientRect1 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
76+
77+
await scheduler.appointmentPopup.selectRepeatValue(t, 'Weekly');
78+
const boundingClientRect2 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
79+
80+
await t.click(scheduler.appointmentPopup.recurrence.backButton);
81+
const boundingClientRect3 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
82+
83+
await t
84+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect2)).ok()
85+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect3)).ok();
86+
}).before(async () => {
87+
await createWidget('dxScheduler', {
88+
dataSource: [],
89+
views: ['week'],
90+
currentView: 'week',
91+
currentDate: new Date(2021, 2, 25),
92+
editing: {
93+
form: {
94+
items: [
95+
{
96+
name: 'mainGroup',
97+
items: ['repeatGroup'],
98+
},
99+
'recurrenceGroup',
100+
],
101+
},
102+
},
103+
});
104+
});
105+
106+
test('Popup should not change dimensions when switching groups and main group height is larger', async (t) => {
107+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
108+
109+
await scheduler.openAppointmentPopup(t);
110+
const boundingClientRect1 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
111+
112+
await scheduler.appointmentPopup.selectRepeatValue(t, 'Weekly');
113+
const boundingClientRect2 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
114+
115+
await t.click(scheduler.appointmentPopup.recurrence.backButton);
116+
const boundingClientRect3 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
117+
118+
await t
119+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect2)).ok()
120+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect3)).ok();
121+
}).before(async () => {
122+
await createWidget('dxScheduler', {
123+
dataSource: [],
124+
views: ['week'],
125+
currentView: 'week',
126+
currentDate: new Date(2021, 2, 25),
127+
editing: {
128+
form: {
129+
items: [
130+
'mainGroup',
131+
{
132+
name: 'recurrenceGroup',
133+
items: ['recurrenceStartDateGroup'],
134+
},
135+
],
136+
},
137+
},
138+
});
139+
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,6 @@ export class AppointmentForm {
897897
}
898898

899899
showMainGroup(): void {
900-
this._popup.updateToolbarForMainGroup();
901-
902900
const currentHeight = this.dxPopup.option('height') as string | number | undefined;
903901
const editingConfig = this.scheduler.getEditingConfig();
904902
const configuredHeight = editingConfig?.popup?.height ?? 'auto';
@@ -918,6 +916,8 @@ export class AppointmentForm {
918916
this._$recurrenceGroup.addClass(CLASSES.recurrenceHidden);
919917
this._$recurrenceGroup.attr('inert', true);
920918
}
919+
920+
this._popup.updateToolbarForMainGroup();
921921
}
922922

923923
showRecurrenceGroup(): void {
@@ -926,8 +926,6 @@ export class AppointmentForm {
926926
repeatEditor.close();
927927
}
928928

929-
this._popup.updateToolbarForRecurrenceGroup();
930-
931929
const currentHeight = this.dxPopup.option('height') as string | number | undefined;
932930

933931
if (currentHeight === 'auto' || currentHeight === undefined) {
@@ -946,6 +944,8 @@ export class AppointmentForm {
946944

947945
this.focusFirstFocusableInGroup(this._$recurrenceGroup);
948946
}
947+
948+
this._popup.updateToolbarForRecurrenceGroup();
949949
}
950950

951951
saveRecurrenceValue(): void {

packages/testcafe-models/scheduler/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ export default class Scheduler extends Widget {
250250

251251
async openAppointmentPopup(
252252
t: TestController,
253-
appointment: any,
254-
isRecurringAppointment: boolean,
253+
appointment?: any,
254+
isRecurringAppointment?: boolean,
255255
): Promise<AppointmentPopup> {
256256
const { getInstance } = this;
257257

0 commit comments

Comments
 (0)