antvis/G6



The issue has been closed
[Bug]: canvas:click will reset all elements's state #7005
mahoushoujoarale posted onGitHub
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 / ęä½ē³»ē»
- macOS
- Windows
- Linux
- Others / å ¶ä»
Browser / ęµč§åØ
- Chrome
- Edge
- Firefox
- Safari (Limited support / ęéęÆę)
- IE (Nonsupport / äøęÆę)
- Others / å ¶ä»