antvis/G6

[Bug]: batchCount variable in batch.ts goes to negative values #7002

niyamaka posted onGitHub

Describe the bug / 问题描述

The events GraphEvent.BATCH_START and GraphEvent.BATCH_END stop to be emitting because the variable this.batchCount goes to negative values. You can see the effect in Redo/Undo Example: when you drag the node and click in undo button the first time works well, but the next time you drag the node and click the undo button the node is moving slow, because the history is fill with many values of AFTER_DRAW event because the context is NOT isBatching. The problem is in the drag-element.ts file: the onDragEnd() calls to endBatch() but the onDragEnd is attach to CommonEvent.DRAG_END and 'blur' and 'contextmenu' events, causing that endBatch() is call several times.

if I comment next lines the problem disappear:

if ($canvas) {
  // $canvas.removeEventListener('blur', this.onDragEnd);
  // $canvas.removeEventListener('contextmenu', this.onDragEnd);
}

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

Thanks for pointing this out — it does look like a bug. Would you be interested in submitting a PR to help fix it? That said, simply commenting out the code might not fully address the root cause, so we may need to dig a bit deeper into the logic together.

posted by yvonneyx 14 days ago
posted by niyamaka 14 days ago

Fund this Issue

$0.00
Funded

Pull requests