The history point location did not meet expectations
- Dominant language
- TypeScript
- Stars
- 12.3k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug / 问题描述
拖拽问题复现步骤.
1.选中点node-0,拖走,点undo,没问题。
2.选中点node-1,拖走,点undo,位置没有直接返回,需要连续点击多次undo才能撤销到初始位置
布局问题复现步骤.
1.切换布局比如到force时,点undo,没有回到布局前的位置
状态记录问题:
点的选中和hover状态都会默认记录到undo中,请问可不可以指定不记录状态
### Reproduction link / 重现链接
_No response_
### 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 } }, { id: 'node-1', style: { x: 300, y: 250 } }]
},
node: {
style: {
size: 60,
labelText: (item)=>item.id,
labelPlacement: 'middle',
labelFill: '#fff',
},
},
behaviors: ['drag-element','click-select','hover-activate'],
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');
gui
.add({ layout: 'circular' }, 'layout', ['circular', 'grid', 'force', 'radial', 'concentric', 'mds'])
.onChange((layout) => {
const options = {
circular: { type: 'circular' },
grid: { type: 'grid' },
force: { type: 'force', preventOverlap: true },
radial: { type: 'radial', preventOverlap: true },
concentric: { type: 'concentric' },
mds: { type: 'mds', linkDistance: 100 },
};
graph.stopLayout();
graph.setLayout(options[layout]);
graph.layout();
});
});
});
### G6 Version / G6 版本
🆕 5.x
### Operating System / 操作系统
macOS
### Browser / 浏览器
Chrome
### Additional context / 补充说明
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the history plugin in the provided G6 reproduction and run the drag, layout-switching, selection, and hover scenarios. Trace which actions are recorded and how undo restores node positions and layouts. Done means each intended user action is undone in one step and selection or hover state is excluded when configured.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100