Skip to content

Scheduler: refactor workspaces module (TS): part 2#33864

Merged
sjbur merged 19 commits into
DevExpress:26_1from
sjbur:issue-4435-26_1_v3
Jun 8, 2026
Merged

Scheduler: refactor workspaces module (TS): part 2#33864
sjbur merged 19 commits into
DevExpress:26_1from
sjbur:issue-4435-26_1_v3

Conversation

@sjbur
Copy link
Copy Markdown
Contributor

@sjbur sjbur commented Jun 5, 2026

No description provided.

@sjbur sjbur self-assigned this Jun 5, 2026
@sjbur sjbur added the 26_1 label Jun 5, 2026
@sjbur sjbur marked this pull request as ready for review June 5, 2026 12:12
@sjbur sjbur requested a review from a team as a code owner June 5, 2026 12:12
Copilot AI review requested due to automatic review settings June 5, 2026 12:12
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

This PR continues the Scheduler workspace TS refactor by moving away from legacy m_* modules and tightening typing across workspace navigation/selection and layout helper utilities.

Changes:

  • Replaced legacy workspace imports (m_*) with refactored modules (e.g. work_space_vertical, helpers/position_helper, selection controller/state).
  • Improved TypeScript typings across workspace render options, cell selection flow, and view-data provider APIs.
  • Introduced/updated helper and model types (e.g. CellPosition) to make workspace interactions more explicit.

Reviewed changes

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

Show a summary per file
File Description
packages/devextreme/js/__internal/scheduler/workspaces/work_space_week.ts Updates week workspace to use refactored vertical workspace module.
packages/devextreme/js/__internal/scheduler/workspaces/work_space_day.ts Updates day workspace to use refactored vertical workspace module.
packages/devextreme/js/__internal/scheduler/workspaces/work_space_vertical.ts Adds explicit return/parameter types for render options and formatting.
packages/devextreme/js/__internal/scheduler/workspaces/work_space_month.ts Adjusts month cell width calculation typing/return behavior.
packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_provider.ts Tightens return type for findCellPositionInMap and imports shared types.
packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_types.ts Adds shared position type(s) used by view model / selection flow.
packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_grouped_data_map_provider.ts Updates typings for findCellPositionInMap to align with refactor.
packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts Switches to refactored helpers/controllers and updates selection logic integration.
packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts Refactors/strongly-types position helper utilities and strategies.
packages/devextreme/js/__internal/scheduler/workspaces/cells_selection_state.ts Adds stronger typing for focused/selected cell state handling.
packages/devextreme/js/__internal/scheduler/workspaces/cells_selection_controller.ts Adds typed navigation logic for keyboard-based cell selection.
Comments suppressed due to low confidence (5)

packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts:162

  • position is a number (result of getMaxAllowedPosition), but it is being cast to number[] and indexed. This makes currentPosition always undefined at runtime, so the correction branch never runs and group width calculations can be wrong.
    packages/devextreme/js/__internal/scheduler/workspaces/cells_selection_controller.ts:65
  • After making focusedCellPosition optional, handleArrowClick should guard before using it; otherwise the method will still throw when focusedCellPosition is missing.
    packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts:49
  • getCellSize can be called when DOM metadata contains placeholder objects (e.g. [[{}]] when there is no window / no cells). In that case, cellSize.width/height will be undefined at runtime, but the function returns them as numbers, which can propagate NaN into downstream layout calculations.
    packages/devextreme/js/__internal/scheduler/workspaces/cells_selection_controller.ts:18
  • focusedCellPosition comes from ViewDataProvider.findCellPositionInMap, which can return undefined. Making it optional here avoids forcing callers to assert non-null, and pairs with a runtime guard in handleArrowClick.
    packages/devextreme/js/__internal/scheduler/workspaces/cells_selection_controller.ts:127
  • If focusedCellPosition is allowed to be undefined (e.g. when the view data map can’t resolve a position), this destructuring will throw. Either guard earlier (as in handleArrowClick) and use a non-null assertion here, or add a local fallback/guard in this method too.

Copilot AI review requested due to automatic review settings June 5, 2026 13:41
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 13 out of 13 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts:49

  • getCellSize can return undefined dimensions when getDOMElementsMetaData() provides placeholder objects like [[{}]] (e.g., no DOM / no cells). That propagates as NaN in width/height calculations. Please default missing width/height to 0.
    packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts:104
  • getAllDayHeight can return undefined when DOM meta arrays contain placeholder objects (e.g., {} from getAllDayPanelDOMElementsInfo() / getDateTableDOMElementsInfo()), which then breaks calculations relying on numeric heights. Please normalize missing heights to 0.
    packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts:163
  • getGroupWidth treats the result of getMaxAllowedPosition(...) as an array (position[groupIndex]), but getMaxAllowedPosition returns a single number. This makes the correction block effectively dead and can return incorrect group widths (especially in RTL). Compute the current/prev/next positions by calling getMaxAllowedPosition for the needed group indices instead of indexing into a scalar.

Comment thread packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_types.ts Outdated
Copilot AI review requested due to automatic review settings June 5, 2026 14: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 13 out of 13 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings June 5, 2026 14:49
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 13 out of 13 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

packages/devextreme/js/__internal/scheduler/workspaces/cells_selection_state.ts:77

  • setSelectedCells may call viewDataProvider.getCellsBetween with firstCell being null when firstCellCoordinates is omitted (e.g. multi-selection starts before firstSelectedCell is initialized). The current firstCell as ViewCellData cast hides this and can cause a runtime exception inside getCellsBetween (it dereferences first.startDate). Prefer a safe fallback to lastCell when firstCell is not set, and store the resolved value back into firstSelectedCell.
    packages/devextreme/js/__internal/scheduler/workspaces/helpers/position_helper.ts:9
  • DOMMetaData is typed as DOMRect[][] / DOMRect[], but the metadata produced by SchedulerWorkSpace.addCellMetaData is a plain object with only { left, top, width, height }. Using DOMRect here is misleading and suggests additional fields (e.g. right, bottom, x, y) exist. Consider introducing a dedicated cell-rect type matching the actual shape.

Copilot AI review requested due to automatic review settings June 5, 2026 15:13
@@ -83,50 +142,33 @@ export const getGroupWidth = (groupIndex, viewDataProvider, options) => {
result = groupLength * cellWidth;
}

const position = getMaxAllowedPosition(
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.

Dead code. getMaxAllowedPosition always returned a number, not an array. In following lines the code tried to access the value from getMaxAllowedPosition as array, which is nonsense

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 16 out of 16 changed files in this pull request and generated no new comments.

)
: this.firstSelectedCell;
const lastCell = viewDataProvider.getCellData(lastRowIndex, lastColumnIndex, isLastCellAllDay);
: (this.firstSelectedCell ?? lastCell);
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.

Added a fallback for firstSelectedCell, because it can be undefined

const dateTableCells = this.getAllCells(false);
if (!dateTableCells.length || !hasWindow()) {
return [[{}]];
return [[{
Copy link
Copy Markdown
Contributor Author

@sjbur sjbur Jun 5, 2026

Choose a reason for hiding this comment

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

Changed for type compatibility reasons and to remove useless type guards. Should not affect anything

this.positionHelper = new PositionHelper({
key: this.option('key'),
viewDataProvider: this.viewDataProvider,
viewStartDayHour: this.option('startDayHour'),
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.

Those props were not actually being used

aleksei-semikozov and others added 2 commits June 5, 2026 13:12
# Conflicts:
#	packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_grouped_data_map_provider.ts
Copilot AI review requested due to automatic review settings June 8, 2026 07:24
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 16 out of 16 changed files in this pull request and generated no new comments.

@sjbur sjbur merged commit 531e01e into DevExpress:26_1 Jun 8, 2026
103 checks passed
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.

5 participants