Skip to content

Commit 8290452

Browse files
authored
Scheduler - Form - Fix scrollbar when opening recurrence group (#31531)
1 parent a380f96 commit 8290452

File tree

6 files changed

+63
-34
lines changed

6 files changed

+63
-34
lines changed
Loading

packages/devextreme-scss/scss/widgets/base/scheduler/_index.scss

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -469,28 +469,33 @@ $scheduler-appointment-form-label-padding: 20px;
469469
}
470470

471471
.dx-form {
472+
min-height: 100%;
472473
position: relative;
473474
overflow: hidden;
474475

475476
.dx-scheduler-form-main-group {
477+
width: 100%;
476478
transition: transform 0.3s ease-in-out;
477479
transform: translateX(0);
480+
position: relative;
478481

479-
&.dx-scheduler-form-main-hidden {
482+
&.dx-scheduler-form-main-group-hidden {
480483
transform: translateX(-100%);
484+
position: absolute;
485+
top: 0;
481486
}
482487
}
483488

484489
.dx-scheduler-form-recurrence-group {
485-
position: absolute;
486-
top: 0;
487-
left: 0;
488490
width: 100%;
489491
transition: transform 0.3s ease-in-out;
490-
transform: translateX(100%);
492+
transform: translateX(0);
493+
position: relative;
491494

492-
&:not(.dx-scheduler-form-recurrence-hidden) {
493-
transform: translateX(0);
495+
&.dx-scheduler-form-recurrence-group-hidden {
496+
transform: translateX(100%);
497+
position: absolute;
498+
top: 0;
494499
}
495500
}
496501

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { setupSchedulerTestEnvironment } from '../__tests__/__mock__/m_mock_sche
1212
const CLASSES = {
1313
icon: 'dx-scheduler-form-icon',
1414
hidden: 'dx-hidden',
15+
16+
mainGroupHidden: 'dx-scheduler-form-main-group-hidden',
17+
recurrenceGroupHidden: 'dx-scheduler-form-recurrence-group-hidden',
1518
};
1619

1720
const getDefaultData = () => [
@@ -436,24 +439,32 @@ describe('Appointment Popup Form', () => {
436439
});
437440

438441
describe('Recurrence', () => {
439-
it('Recurrence editor container should be visible after changing its visibility value', async () => {
440-
const appointment = {
441-
text: 'Test Appointment',
442-
startDate: new Date(2017, 4, 1, 9, 30),
443-
endDate: new Date(2017, 4, 1, 11),
444-
};
445-
446-
const { POM, scheduler } = await createScheduler(getDefaultConfig());
442+
it('changes visibility of groups when opening recurrence form', async () => {
443+
const { scheduler, POM } = await createScheduler(getDefaultConfig());
447444

448-
scheduler.showAppointmentPopup(appointment);
445+
scheduler.showAppointmentPopup();
449446

447+
const mainGroup = $(POM.popup.mainGroup);
450448
const recurrenceGroup = $(POM.popup.recurrenceGroup);
451449

452-
expect(recurrenceGroup.hasClass('dx-scheduler-form-recurrence-hidden')).toBe(true);
450+
expect(mainGroup.hasClass(CLASSES.mainGroupHidden)).toBe(false);
451+
expect(recurrenceGroup.hasClass(CLASSES.recurrenceGroupHidden)).toBe(true);
453452

454453
POM.popup.selectRepeatValue('weekly');
454+
await new Promise(process.nextTick);
455+
456+
const popupHeight = POM.popup.component.option('height');
457+
expect(popupHeight).toBeDefined();
458+
expect(typeof popupHeight).toBe('number');
459+
460+
expect(mainGroup.hasClass(CLASSES.mainGroupHidden)).toBe(true);
461+
expect(recurrenceGroup.hasClass(CLASSES.recurrenceGroupHidden)).toBe(false);
462+
463+
POM.popup.getBackButton().click();
455464

456-
expect(recurrenceGroup.hasClass('dx-scheduler-form-recurrence-hidden')).toBe(false);
465+
expect(POM.popup.component.option('height')).toBeUndefined();
466+
expect(mainGroup.hasClass(CLASSES.mainGroupHidden)).toBe(false);
467+
expect(recurrenceGroup.hasClass(CLASSES.recurrenceGroupHidden)).toBe(true);
457468
});
458469

459470
it('Check that after opening recurrence appointment current form is main form', async () => {
@@ -472,7 +483,7 @@ describe('Appointment Popup Form', () => {
472483

473484
const recurrenceGroup = $(POM.popup.recurrenceGroup);
474485

475-
expect(recurrenceGroup.hasClass('dx-scheduler-form-recurrence-hidden')).toBe(true);
486+
expect(recurrenceGroup.hasClass(CLASSES.recurrenceGroupHidden)).toBe(true);
476487
});
477488

478489
it('Should discard recurrence changes when clicking \'cancel\' button in recurrence form', async () => {

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

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { TextEditorButton } from '@js/common';
22
import messageLocalization from '@js/common/core/localization/message';
33
import { DataSource } from '@js/common/data';
4+
import type { dxElementWrapper } from '@js/core/renderer';
45
import $ from '@js/core/renderer';
56
import dateUtils from '@js/core/utils/date';
67
import { extend } from '@js/core/utils/extend';
@@ -10,12 +11,13 @@ import type {
1011
GroupItem, Item as FormItem, Properties as FormProperties, SimpleItem,
1112
} from '@js/ui/form';
1213
import dxForm from '@js/ui/form';
13-
import type { Properties as SchedulerProperties } from '@js/ui/scheduler';
14+
import type { AppointmentFormIconsShowMode, Properties as SchedulerProperties } from '@js/ui/scheduler';
1415
import type { Properties as SelectBoxProperties } from '@js/ui/select_box';
1516
import type { Properties as SwitchProperties } from '@js/ui/switch';
1617
import type { Properties as TextAreaProperties } from '@js/ui/text_area';
1718
import { current, isFluent } from '@js/ui/themes';
1819
import { dateSerialization } from '@ts/core/utils/m_date_serialization';
20+
import type Popup from '@ts/ui/popup/m_popup';
1921

2022
import timeZoneUtils from '../m_utils_time_zone';
2123
import type { SafeAppointment } from '../types';
@@ -59,9 +61,9 @@ const CLASSES = {
5961
descriptionEditor: 'dx-scheduler-form-description-editor',
6062

6163
recurrenceSettingsButton: 'dx-scheduler-form-recurrence-settings-button',
62-
mainHidden: 'dx-scheduler-form-main-hidden',
64+
mainHidden: 'dx-scheduler-form-main-group-hidden',
6365
recurrenceGroup: 'dx-scheduler-form-recurrence-group',
64-
recurrenceHidden: 'dx-scheduler-form-recurrence-hidden',
66+
recurrenceHidden: 'dx-scheduler-form-recurrence-group-hidden',
6567
};
6668

6769
const EDITOR_NAMES = {
@@ -120,10 +122,18 @@ export class AppointmentForm {
120122

121123
private _popup!: any;
122124

125+
private _$mainGroup?: dxElementWrapper;
126+
127+
private _$recurrenceGroup?: dxElementWrapper;
128+
123129
get dxForm(): dxForm {
124130
return this._dxForm as dxForm;
125131
}
126132

133+
private get dxPopup(): Popup {
134+
return this._popup.dxPopup as Popup;
135+
}
136+
127137
get readOnly(): boolean {
128138
return this.dxForm.option('readOnly') as boolean;
129139
}
@@ -195,7 +205,7 @@ export class AppointmentForm {
195205
this.createForm(items);
196206
}
197207

198-
private getIconsShowMode(): 'main' | 'recurrence' | 'both' | 'none' {
208+
private getIconsShowMode(): AppointmentFormIconsShowMode {
199209
const editingConfig = this.scheduler.getEditingConfig() as SchedulerProperties['editing'];
200210

201211
if (isBoolean(editingConfig)) {
@@ -257,6 +267,11 @@ export class AppointmentForm {
257267
this._dxForm = e.component;
258268
this._recurrenceForm.dxForm = this.dxForm;
259269
},
270+
onContentReady: (e): void => {
271+
const $formElement = e.component.$element();
272+
this._$mainGroup = $formElement.find(`.${CLASSES.mainGroup}`);
273+
this._$recurrenceGroup = $formElement.find(`.${CLASSES.recurrenceGroup}`);
274+
},
260275
} as FormProperties) as dxForm;
261276
}
262277

@@ -751,12 +766,11 @@ export class AppointmentForm {
751766
}
752767

753768
showRecurrenceGroup(): void {
754-
const $formElement = $(this.dxForm.element());
755-
const mainGroup = $formElement.find(`.${CLASSES.mainGroup}`);
756-
const recurrenceGroup = $formElement.find(`.${CLASSES.recurrenceGroup}`);
769+
const overlayHeight = this.dxPopup.$overlayContent().get(0).clientHeight;
770+
this.dxPopup.option('height', overlayHeight);
757771

758-
mainGroup.addClass(CLASSES.mainHidden);
759-
recurrenceGroup.removeClass(CLASSES.recurrenceHidden);
772+
this._$mainGroup?.addClass(CLASSES.mainHidden);
773+
this._$recurrenceGroup?.removeClass(CLASSES.recurrenceHidden);
760774

761775
const repeatEditorValue = this.dxForm.getEditor(EDITOR_NAMES.repeat)?.option('value');
762776

@@ -770,12 +784,10 @@ export class AppointmentForm {
770784
}
771785

772786
showMainGroup(saveRecurrenceValue = true): void {
773-
const $formElement = $(this.dxForm.element());
774-
const mainGroup = $formElement.find(`.${CLASSES.mainGroup}`);
775-
const recurrenceGroup = $formElement.find(`.${CLASSES.recurrenceGroup}`);
787+
this.dxPopup.option('height', undefined);
776788

777-
mainGroup.removeClass(CLASSES.mainHidden);
778-
recurrenceGroup.addClass(CLASSES.recurrenceHidden);
789+
this._$mainGroup?.removeClass(CLASSES.mainHidden);
790+
this._$recurrenceGroup?.addClass(CLASSES.recurrenceHidden);
779791

780792
this._popup.updateToolbarForMainGroup();
781793

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export class AppointmentPopup {
106106
},
107107
contentTemplate: (): dxElementWrapper => {
108108
this.form.create({
109+
dxPopup: this.popup,
109110
updateToolbarForMainGroup: (): void => this.updateToolbarForMainGroup(),
110111
updateToolbarForRecurrenceGroup: (): void => this.updateToolbarForRecurrenceGroup(),
111112
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const CLASSES = {
2020
formIcon: 'dx-scheduler-form-icon',
2121

2222
recurrenceGroup: 'dx-scheduler-form-recurrence-group',
23-
recurrenceHidden: 'dx-scheduler-form-recurrence-hidden',
23+
recurrenceHidden: 'dx-scheduler-form-recurrence-group-hidden',
2424

2525
frequencyEditor: 'dx-scheduler-form-recurrence-frequency-editor',
2626
byMonthEditor: 'dx-scheduler-form-recurrence-by-month-editor',

0 commit comments

Comments
 (0)