Version
1.22.5
Link to Minimal Reproduction
https://codesandbox.io/p/sandbox/blue-violet-lmvdjx?file=%2Fsrc%2Findex.mjs%3A70%2C7
Steps to Reproduce
- 初始化 VTable Gantt,设置
tasksShowMode 为 Sub_Tasks_Inline(或 Sub_Tasks_Compact,即子任务在同一行显示的模式)。
- 构造数据场景:
- 场景A:某一行的任务数据为空(例如没有子任务,或者时间无效导致未渲染任务条)。
- 场景B:某一行的任务数据包含多个子任务(例如同一行显示了 Task 1-1 和 Task 1-2)。
- 调用 API
ganttInstance.getTaskBarRelativeRect(taskIndex)。
// Example Code Logic
const gantt = new VTableGantt.Gantt(dom, {
tasksShowMode: VTableGantt.TYPES.TasksShowMode.Sub_Tasks_Inline,
// ...
});
// 1. Trigger error
// Assuming index 0 has no valid task bar to render
try {
gantt.getTaskBarRelativeRect(0);
} catch (e) {
console.error(e); // TypeError: Cannot read properties of null (reading 'attribute')
}
// 2. Trigger incorrect return value
// Assuming index 1 has multiple sub-tasks on the same row
const rect = gantt.getTaskBarRelativeRect(1);
console.log(rect); // Only returns the rect of the FIRST sub-task, ignoring others.
Current Behavior
- 报错问题:当对没有渲染任务条的行索引调用
getTaskBarRelativeRect 时,内部代码未做判空处理,直接访问图形属性导致抛出 TypeError: Cannot read properties of null (reading 'attribute'),导致程序中断。
- 逻辑问题:在紧凑/内联视图模式下,一行内会渲染多个任务条,但目前的 API 仅返回该行 第一个 任务条的位置信息,导致开发者无法获取该行剩余任务的位置(用于自定义悬浮层等场景)。
Expected Behavior
- 健壮性:方法内部应增加空值检查。如果该行未渲染任何任务条,应返回
null 或 undefined,而不是抛出异常。
- 完整性:针对多任务共存一行的场景,该 API 应该支持返回一个位置数组
Rect[],包含该行所有可视任务条的位置信息;或者提供参数支持获取特定子任务。
Environment
- OS: macOS
- Browser: Chrome
- Framework: Vue
Any additional comments?
该问题导致在开发“任务条吸附图标”或“自定义 Overlay”功能时,无法处理紧凑视图下的多任务定位,且容易因为空数据行导致页面崩溃。
Version
1.22.5
Link to Minimal Reproduction
https://codesandbox.io/p/sandbox/blue-violet-lmvdjx?file=%2Fsrc%2Findex.mjs%3A70%2C7
Steps to Reproduce
tasksShowMode为Sub_Tasks_Inline(或Sub_Tasks_Compact,即子任务在同一行显示的模式)。ganttInstance.getTaskBarRelativeRect(taskIndex)。Current Behavior
getTaskBarRelativeRect时,内部代码未做判空处理,直接访问图形属性导致抛出TypeError: Cannot read properties of null (reading 'attribute'),导致程序中断。Expected Behavior
null或undefined,而不是抛出异常。Rect[],包含该行所有可视任务条的位置信息;或者提供参数支持获取特定子任务。Environment
Any additional comments?
该问题导致在开发“任务条吸附图标”或“自定义 Overlay”功能时,无法处理紧凑视图下的多任务定位,且容易因为空数据行导致页面崩溃。