Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {
afterEach, beforeEach, describe, expect, it,
} from '@jest/globals';
import $ from '@js/core/renderer';

import fx from '../../../common/core/animation/fx';
import { createScheduler } from './__mock__/create_scheduler';
import { setupSchedulerTestEnvironment } from './__mock__/m_mock_scheduler';

const CLASSES = {
scheduler: 'dx-scheduler',
workSpace: 'dx-scheduler-work-space',
shaderTop: 'dx-scheduler-date-time-shader-top',
};
Comment on lines +10 to +14
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLASSES object defines 'workSpace' and 'shaderTop' properties that are not used in this test. Consider removing these unused properties or adding additional test assertions that use them to verify the shader rendering behavior.

Copilot uses AI. Check for mistakes.

describe('Workspace', () => {
beforeEach(() => {
fx.off = true;
setupSchedulerTestEnvironment({ height: 600 });
});

afterEach(() => {
const $scheduler = $(document.querySelector(`.${CLASSES.scheduler}`));
// @ts-expect-error
$scheduler.dxScheduler('dispose');
document.body.innerHTML = '';
fx.off = false;
});

it('should use group 0 width as fallback when groups are not rendered due to virtual scrolling (T1310524)', async () => {
const resources = [
{ text: 'Room 1', id: 1, color: '#cb6bb2' },
{ text: 'Room 2', id: 2, color: '#56ca85' },
{ text: 'Room 3', id: 3, color: '#1e90ff' },
{ text: 'Room 4', id: 4, color: '#ff9747' },
{ text: 'Room 5', id: 5, color: '#ff6a00' },
{ text: 'Room 6', id: 6, color: '#ffc0cb' },
];

const { scheduler } = await createScheduler({
currentView: 'week',
views: ['week'],
groups: ['roomId'],
resources: [{ fieldExpr: 'roomId', dataSource: resources, label: 'Room' }],
dataSource: [
{
text: 'Meeting 1', startDate: new Date(2025, 9, 15, 9), endDate: new Date(2025, 9, 15, 10), roomId: 1,
},
{
text: 'Meeting 2', startDate: new Date(2025, 9, 15, 9), endDate: new Date(2025, 9, 15, 10), roomId: 4,
},
],
startDayHour: 8,
endDayHour: 18,
currentDate: new Date(2025, 9, 15),
height: 400,
shadeUntilCurrentTime: true,
scrolling: { mode: 'virtual' },
});

const workSpace = scheduler.getWorkSpace();
const cellCount = workSpace._getCellCount();
const lastGroupWidth = workSpace.getRoundedCellWidth(
resources.length - 1,
(resources.length - 1) * cellCount,
cellCount,
);

expect(lastGroupWidth).toBeGreaterThan(0);
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test assertion only verifies that lastGroupWidth is greater than 0, but doesn't verify that it matches group 0's width. Consider adding an assertion that compares the last group's width to the first group's width to ensure the fallback mechanism is working correctly: expect(lastGroupWidth).toBe(workSpace.getRoundedCellWidth(0, 0, cellCount)).

Copilot uses AI. Check for mistakes.
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1579,13 +1579,24 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
startIndex = totalCellCount;
}

let foundElements = 0;
for (let i = startIndex; i < totalCellCount + cellCount; i++) {
const element = $($cells).eq(i).get(0);
const elementWidth = element ? getBoundingRect(element).width : 0;
width += elementWidth;
if (element) {
foundElements++;
}
Comment on lines +1582 to +1589
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name 'foundElements' could be more descriptive to clarify its purpose. Consider renaming it to 'renderedElementCount' to better convey that it tracks the number of DOM elements that were actually found and rendered.

Copilot uses AI. Check for mistakes.
}

return width / (totalCellCount + cellCount - startIndex);
const divisor = totalCellCount + cellCount - startIndex;
let result = width / divisor;

Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback logic for handling virtualized groups that are not rendered in the DOM is not documented. Consider adding a comment explaining that when virtual scrolling is enabled and a group is not rendered, this fallback uses group 0's cell width as a reference, which is needed for proper shader rendering via the shadeUntilCurrentTime feature.

Suggested change
// When virtual scrolling is enabled, cells for some groups may not be rendered in the DOM.
// In that case, the computed width can be 0 with no elements found for the target group.
// To keep features such as shadeUntilCurrentTime working correctly, fall back to using
// group 0's cell width as a reference for shader rendering.

Copilot uses AI. Check for mistakes.
if (result === 0 && groupIndex > 0 && foundElements === 0) {
result = this.getRoundedCellWidth(0, 0, cellCount);
}

return result;
}

// Mappings
Expand Down
Loading