antvis/G6

drag-canvas and brush select do not work properly together. #5793

RackweLLizm posted onGitHub

Describe the bug

behaviors: [
 {
 type: 'click-element',
 multiple: true,
 trigger: ['shift']
 },
 {
 key: 'brush-select',
 type: 'brush-select',
 mode: 'diff',
 trigger: 'shift',
 style: {
 fill: '#00f',
 fillOpacity: 0.2,
 stroke: '#0ff',
 },
 },
 {
 type: 'create-edge',
 key: 'create-edge',
 trigger: 'click',
 enable: false,
 animation: true
 },
 'zoom-canvas',
 // 'drag-canvas',
 'drag-element'
 ],

When drag-canvas and brush select are opened at the same time, brush select does not work properly in the graphic.

Your Example Website or App

notFound

Steps to Reproduce the Bug or Issue

1-) Brush Select Active 2-) Drag Canvas Active

Try to make a selection with the Shift key on the canvas, it will not work properly.

Expected behavior

brush select should work

Screenshots or Videos

No response

Platform

Windows Chrome 124 "@antv/g6": "^5.0.0-beta.37",

Additional context

No response


Thanks, I will verify the problem soon

posted by Aarebecca 11 months ago

@Aarebecca This error still persists in version 5.0.1. Is there any progress

posted by RackweLLizm 11 months ago

@hustcc https://stackblitz.com/edit/rackwellizm?file=index.html,index.js Here is an example from stackbilitz. Selection can be made with the shift key.

posted by RackweLLizm 10 months ago

A simple solution is to use the information in the event to determine which interaction should be used at this time, such as the following options to enable drag canvas when pressing 'shiftKey' and dragging, and brush select when dragging directly

behaviors: [
  {
    type: 'brush-select',
    key: 'brush-select',
    trigger: 'drag',
    enable: (event) => event.shiftKey !== true,
  },
  {
    type: 'drag-canvas',
    enable: (event) => event.shiftKey === true,
  },
];
posted by Aarebecca 9 months ago

@Aarebecca https://github.com/antvis/G6/pull/6125 I think the above commit solves this problem too.

posted by RackweLLizm 9 months ago

Fund this Issue

$0.00
Funded

Pull requests