Describe the bug / 问题描述
https://github.com/antvis/G6/blob/v5/packages/g6/src/behaviors/click-select.ts
canvas:click will reset all elements's state because of this.getClearStates()
if (type === 'select') {
Object.assign(states, this.getClearStates(!!unselectedState));
const addState = (list: ID[], state: State) => {
list.forEach((id) => {
if (!states[id]) states[id] = graph.getElementState(id);
states[id].push(state);
});
};
addState(click, selectState);
addState(neighbor, neighborState);
if (unselectedState) {
Object.keys(states).forEach((id) => {
if (!click.includes(id) && !neighbor.includes(id)) states[id].push(unselectedState);
});
}
} else Object.assign(states, this.getClearStates());
see https://github.com/antvis/G6/blob/v5/packages/g6/src/behaviors/click-select.ts
it's supposed to be like
else {
const targetState = states[target.id];
states[target.id] = targetState.filter((s) => s !== selectState && s !== neighborState);
if (!targetState.includes(unselectedState)) states[target.id].push(unselectedState);
neighbor.forEach((id) => {
states[id] = states[id].filter((s) => s !== neighborState);
if (!states[id].includes(selectState)) states[id].push(unselectedState);
});
}
in the next few lines
@Aarebecca
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
🆕 5.x
OS / 操作系统
Browser / 浏览器
Describe the bug / 问题描述
https://github.com/antvis/G6/blob/v5/packages/g6/src/behaviors/click-select.ts
canvas:click will reset all elements's state because of this.getClearStates()
see https://github.com/antvis/G6/blob/v5/packages/g6/src/behaviors/click-select.ts
it's supposed to be like
in the next few lines
@Aarebecca
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
🆕 5.x
OS / 操作系统
Browser / 浏览器