Skip to content

Scheduler - Appointments Refactoring - Rendering fixes#33249

Merged
Tucchhaa merged 8 commits intoDevExpress:26_1from
Tucchhaa:fix_rendering_26_1
Apr 14, 2026
Merged

Scheduler - Appointments Refactoring - Rendering fixes#33249
Tucchhaa merged 8 commits intoDevExpress:26_1from
Tucchhaa:fix_rendering_26_1

Conversation

@Tucchhaa
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 14, 2026 05:16
@Tucchhaa Tucchhaa requested a review from a team as a code owner April 14, 2026 05:16
@Tucchhaa Tucchhaa added the 26_1 label Apr 14, 2026
@Tucchhaa Tucchhaa self-assigned this Apr 14, 2026
private appointmentBySortIndex: Record<number, AppointmentComponent> = {};
private viewItemBySortedIndex: Record<number, ViewItem> = {};

private viewItems: ViewItem[] = [];
Copy link
Copy Markdown
Contributor Author

@Tucchhaa Tucchhaa Apr 14, 2026

Choose a reason for hiding this comment

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

This variable contains the same value as viewItemBySortedIndex, but as a flat array.

It's not used in the current code, but will be used in the next PR with the focus state.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Scheduler “appointments_new” rendering/diffing to preserve existing appointment view instances when sortedIndex shifts (e.g., insert/remove in the middle), and adds a CSS class marker for appointments that have a resource color applied.

Changes:

  • Extend view model diff items to carry oldSortedIndex for matched items, enabling stable lookup of existing rendered items after re-sorting.
  • Refactor Appointments rendering to maintain a sortedIndex -> view item map and reuse items during partial updates.
  • Add APPOINTMENT_TYPE_CLASSES.HAS_RESOURCE and apply it when resource color is present (grid + agenda), with accompanying tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/devextreme/js/__internal/scheduler/appointments_new/utils/get_view_model_diff.ts Adds oldSortedIndex to diff output for matched items.
packages/devextreme/js/__internal/scheduler/appointments_new/utils/get_view_model_diff.test.ts Updates expectations to validate oldSortedIndex behavior.
packages/devextreme/js/__internal/scheduler/appointments_new/const.ts Adds HAS_RESOURCE appointment type class constant.
packages/devextreme/js/__internal/scheduler/appointments_new/appointments.ts Refactors rendering to reuse view instances across sortedIndex shifts; adds view-item accessors.
packages/devextreme/js/__internal/scheduler/appointments_new/appointments.test.ts Adds tests ensuring items are not recreated when sortedIndex shifts due to insert/remove.
packages/devextreme/js/__internal/scheduler/appointments_new/appointment/base_appointment.ts Changes resize signature to accept optional geometry param.
packages/devextreme/js/__internal/scheduler/appointments_new/appointment/grid_appointment.ts Updates resize to accept optional geometry; adds HAS_RESOURCE class when color applied.
packages/devextreme/js/__internal/scheduler/appointments_new/appointment/grid_appointment.test.ts Adjusts geometry test to call resize(geometry); adds HAS_RESOURCE class test.
packages/devextreme/js/__internal/scheduler/appointments_new/appointment/agenda_appointment.ts Updates resize to accept optional geometry; adds HAS_RESOURCE class when color applied.
packages/devextreme/js/__internal/scheduler/appointments_new/appointment/agenda_appointment.test.ts Adds geometry tests for init + resize(geometry); adds HAS_RESOURCE class test.

// TODO: remove passing index to appointmentTemplate, need only to avoid BC
viewModelDiff.forEach((diffItem, index) => {
const { allDay, sortedIndex } = diffItem.item;
const lookupIndex = diffItem.oldSortedIndex ?? sortedIndex;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without lookup index, this case wouldn't work:

const InitialViewModel = [
   { data: 'A', sortedIndex: 0 },
   { data: 'B', sortedIndex: 1 }
]
renderViewModelDiff(InitialViewModel) ->
viewItemBySortedIndex == {
   0: 'A'
   1: 'B'
}

const nextViewModel = [
   { data: 'A', sortedIndex: 0 },
   { data: 'New', sortedIndex: 1 },
   { data: 'B', sortedIndex: 2 }
]
renderViewModelDiff(InitialViewModel) ->
viewItemBySortedIndex == {
   0: 'A'
   1: 'New',
   2: undefined
}

That's because get_view_model_diff doesn't compare sortedIndex between items. So since the 'B' item didn't have any changes, it wouldn't be rerendered, but the index to access the element from this.viewItemBySortedIndex will be 2, which is not defined.

Copilot AI review requested due to automatic review settings April 14, 2026 07:14
});

describe('Geometry', () => {
it('should apply geometry on init', async () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In agenda view on viewModel change all view items are rerendered, so there's no test for .resize() function, as agenda appointment is resized only at the creation

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings April 14, 2026 12:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings April 14, 2026 12:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

@Tucchhaa Tucchhaa merged commit f4917d1 into DevExpress:26_1 Apr 14, 2026
132 of 133 checks passed
@Tucchhaa Tucchhaa deleted the fix_rendering_26_1 branch April 14, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants