antvis/G6

[Bug]: brush-select not work well with undo/redo feature #6842

Rey-Wang posted onGitHub

Describe the bug / 问题描述

when use brush-select and drag the selected elements, undo/redo not work well

no link, you can reproduce on offical examples

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

import { Graph } from '@antv/g6';

const graph = new Graph({
  container: 'container',
  data: {
    nodes: [{ id: 'node-0', style: { x: 200, y: 150 } }],
  },
  node: {
    style: {
      size: 60,
      labelText: 'Drag Me!',
      labelPlacement: 'middle',
      labelFill: '#fff',
    },
  },
  behaviors: ['drag-element',
   {
        type: 'brush-select',
        immediately: true,
        mode: 'default',
        enableElements: ['node', 'combo'],
      },],
  plugins: [
    {
      type: 'history',
      key: 'history',
    },
  ],
});

graph.render().then(() => {
  window.addPanel((gui) => {
    const history = graph.getPluginInstance('history');
    const config = {
      undo: () => {
        if (history.canUndo()) history.undo();
      },
      redo: () => {
        if (history.canRedo()) history.redo();
      },
    };
    gui.add(config, 'undo').name('⬅️ undo');
    gui.add(config, 'redo').name('➡️ redo');
  });
});

Version / 版本

🆕 5.x

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

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

It appears that the issue you are experiencing has already been reported as Issue #6842 in the antvis/G6 repository. Unfortunately, there are no other related issues or solutions available at the moment.

To address this, you might consider the following steps:

  1. Check for Updates: Ensure that you are using the latest version of antvis/g6, as updates may contain fixes for this issue.

  2. Workaround: As a temporary workaround, you might try implementing custom logic to handle undo/redo operations for brush-selected elements, although this might require additional coding.

  3. Monitor the Issue: Keep an eye on the issue page for any updates or comments from the maintainers or community members.

If you have any further questions or need additional assistance, feel free to ask!

<details> <summary>🪧 Tips</summary> For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. </details>

posted by petercat-assistant[bot] about 2 months ago

The history plugin listens to the draw event. Every time the draw event is executed, the record will be saved. This is to ensure its universality. If you want it to meet specific business requirements, you need to do some processing on its record stack.

posted by zhongyunWan about 2 months ago

Fund this Issue

$0.00
Funded

Pull requests