Skip to content

Commit 3f95a89

Browse files
authored
Scheduler: AllDay panel cells are misaligned with the main table on MacOS if the scrollbar is visible by default (#31247)
1 parent fcff059 commit 3f95a89

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed
35.8 KB
Loading
36.3 KB
Loading

e2e/testcafe-devextreme/tests/scheduler/common/header/header.ts

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
12
import Scheduler from 'devextreme-testcafe-models/scheduler';
23
import { createWidget } from '../../../../helpers/createWidget';
34
import url from '../../../../helpers/getPageUrl';
5+
import { insertStylesheetRulesToPage, removeStylesheetRulesFromPage } from '../../../../helpers/domUtils';
46

57
fixture.disablePageReloads`Scheduler header`
68
.page(url(__dirname, '../../../container.html'));
@@ -42,3 +44,144 @@ test('dateNavigator buttons should have "contained" styling mode with generic th
4244
views: ['day'],
4345
height: 580,
4446
}));
47+
48+
const testData = [
49+
{
50+
text: 'Website Re-Design Plan',
51+
startDate: new Date('2021-03-29T16:30:00.000Z'),
52+
endDate: new Date('2021-03-29T18:30:00.000Z'),
53+
}, {
54+
text: 'Book Flights to San Fran for Sales Trip',
55+
startDate: new Date('2021-03-29T19:00:00.000Z'),
56+
endDate: new Date('2021-03-29T20:00:00.000Z'),
57+
allDay: true,
58+
}, {
59+
text: 'Install New Router in Dev Room',
60+
startDate: new Date('2021-03-29T21:30:00.000Z'),
61+
endDate: new Date('2021-03-29T22:30:00.000Z'),
62+
}, {
63+
text: 'Approve Personal Computer Upgrade Plan',
64+
startDate: new Date('2021-03-30T17:00:00.000Z'),
65+
endDate: new Date('2021-03-30T18:00:00.000Z'),
66+
}, {
67+
text: 'Final Budget Review',
68+
startDate: new Date('2021-03-30T19:00:00.000Z'),
69+
endDate: new Date('2021-03-30T20:35:00.000Z'),
70+
}, {
71+
text: 'New Brochures',
72+
startDate: new Date('2021-03-30T21:30:00.000Z'),
73+
endDate: new Date('2021-03-30T22:45:00.000Z'),
74+
}, {
75+
text: 'Install New Database',
76+
startDate: new Date('2021-03-31T16:45:00.000Z'),
77+
endDate: new Date('2021-03-31T18:15:00.000Z'),
78+
}, {
79+
text: 'Approve New Online Marketing Strategy',
80+
startDate: new Date('2021-03-31T19:00:00.000Z'),
81+
endDate: new Date('2021-03-31T21:00:00.000Z'),
82+
}, {
83+
text: 'Upgrade Personal Computers',
84+
startDate: new Date('2021-03-31T22:15:00.000Z'),
85+
endDate: new Date('2021-03-31T23:30:00.000Z'),
86+
}, {
87+
text: 'Customer Workshop',
88+
startDate: new Date('2021-04-01T18:00:00.000Z'),
89+
endDate: new Date('2021-04-01T19:00:00.000Z'),
90+
allDay: true,
91+
}, {
92+
text: 'Prepare 2021 Marketing Plan',
93+
startDate: new Date('2021-04-01T18:00:00.000Z'),
94+
endDate: new Date('2021-04-01T20:30:00.000Z'),
95+
}, {
96+
text: 'Brochure Design Review',
97+
startDate: new Date('2021-04-01T21:00:00.000Z'),
98+
endDate: new Date('2021-04-01T22:30:00.000Z'),
99+
}, {
100+
text: 'Create Icons for Website',
101+
startDate: new Date('2021-04-02T17:00:00.000Z'),
102+
endDate: new Date('2021-04-02T18:30:00.000Z'),
103+
}, {
104+
text: 'Upgrade Server Hardware',
105+
startDate: new Date('2021-04-02T21:30:00.000Z'),
106+
endDate: new Date('2021-04-02T23:00:00.000Z'),
107+
}, {
108+
text: 'Submit New Website Design',
109+
startDate: new Date('2021-04-02T23:30:00.000Z'),
110+
endDate: new Date('2021-04-03T01:00:00.000Z'),
111+
}, {
112+
text: 'Launch New Website',
113+
startDate: new Date('2021-04-02T19:20:00.000Z'),
114+
endDate: new Date('2021-04-02T21:00:00.000Z'),
115+
},
116+
];
117+
118+
const SCROLLBAR_STYLES = `
119+
::-webkit-scrollbar {
120+
-webkit-appearance: none;
121+
width: 7px;
122+
}
123+
::-webkit-scrollbar-thumb {
124+
border-radius: 4px;
125+
background-color: rgba(0, 0, 0, .5);
126+
-webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
127+
}
128+
.dx-scheduler-date-table-scrollable .dx-scrollable-container {
129+
overflow: scroll !important;
130+
}
131+
`;
132+
133+
test('Scheduler: maintain layout after horizontal scroll (T1306971)', async (t) => {
134+
const {
135+
takeScreenshot,
136+
compareResults,
137+
} = createScreenshotsComparer(t);
138+
const scheduler = new Scheduler('#container');
139+
140+
await insertStylesheetRulesToPage(SCROLLBAR_STYLES);
141+
142+
await t.wait(100);
143+
144+
await scheduler.repaint();
145+
146+
await t.wait(100);
147+
148+
await t.expect(
149+
await takeScreenshot('T1306971__scheduler__horizontal-scrolling__before.png', scheduler.element),
150+
).ok();
151+
152+
const container = scheduler.dateTableScrollableContainer;
153+
const scrollWidth = await container.scrollWidth;
154+
const clientWidth = await container.clientWidth;
155+
const maxScrollLeft = scrollWidth - clientWidth;
156+
157+
await t.scroll(scheduler.workspaceScrollable, maxScrollLeft, 0);
158+
159+
const finalScrollLeft = await container.scrollLeft;
160+
161+
await t
162+
.expect(maxScrollLeft).gt(0, 'No horizontal scroll available')
163+
.expect(finalScrollLeft).gt(0, 'Scroll position should be greater than 0');
164+
165+
await t.wait(500);
166+
167+
await t.expect(
168+
await takeScreenshot('T1306971__scheduler__horizontal-scrolling__after.png', scheduler.element),
169+
).ok();
170+
171+
await t.expect(compareResults.isValid())
172+
.ok(compareResults.errorMessages());
173+
}).before(async () => {
174+
await createWidget('dxScheduler', {
175+
timeZone: 'America/Los_Angeles',
176+
dataSource: testData,
177+
views: ['week'],
178+
currentView: 'week',
179+
currentDate: new Date(2021, 2, 28),
180+
startDayHour: 9,
181+
height: 730,
182+
crossScrollingEnabled: true,
183+
width: 500,
184+
});
185+
}).after(async () => {
186+
await removeStylesheetRulesFromPage();
187+
});

packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,19 @@ class SchedulerWorkSpace extends WidgetObserver {
861861
}
862862
}
863863

864+
updateHeaderPanelScrollbarPadding() {
865+
if (hasWindow() && this._$headerPanelContainer) {
866+
const scrollbarWidth = this._getScrollbarWidth();
867+
this._$headerPanelContainer.css('paddingRight', `${scrollbarWidth}px`);
868+
}
869+
}
870+
871+
_getScrollbarWidth() {
872+
const containerElement = $(this._dateTableScrollable.container()).get(0) as HTMLElement;
873+
const scrollbarWidth = containerElement.offsetWidth - containerElement.clientWidth;
874+
return scrollbarWidth;
875+
}
876+
864877
_isGroupsSpecified(resources) {
865878
return this.option('groups')?.length && resources;
866879
}
@@ -1043,6 +1056,7 @@ class SchedulerWorkSpace extends WidgetObserver {
10431056
this._dateTableScrollable.update();
10441057
this._headerScrollable?.update();
10451058
this._sidebarScrollable?.update();
1059+
this.updateHeaderPanelScrollbarPadding();
10461060
}
10471061

10481062
_getTimePanelRowCount() {

0 commit comments

Comments
 (0)