Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag selection is dropped when mouse is outside the pane or when mouse encounters outside elements #4203

Open
hiepnguyen3001 opened this issue Apr 24, 2024 · 2 comments

Comments

@hiepnguyen3001
Copy link

Describe the Bug

When using drag select, selection is drag selection is immediately dropped when mouse is outside the pane or when mouse encounters outside elements, even when mouse button has not been released. This makes drag selection unusable if I want to place something in the middle of the pane.

Your Example Website or App

https://codesandbox.io/p/sandbox/suspicious-pond-cxypq3?file=%2FApp.js%3A76%2C34

Steps to Reproduce the Bug or Issue

  1. Start drag selection
  2. Drag mouse outside the pane or to "Floating bar" div (see codesandbox above)

Expected behavior

Drag selection persists even when mouse is outside the pane or when mouse encounters outside elements

Screenshots or Videos

Screen.Recording.2024-04-24.at.17.27.55.mov

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 123.0.2420.97

Additional context

No response

@V3RON
Copy link

V3RON commented Apr 26, 2024

This problem originates from Pane component:

<div
      className={cc(['react-flow__pane', { draggable: panOnDrag, dragging, selection: isSelecting }])}
      onClick={hasActiveSelection ? undefined : wrapHandler(onClick, container)}
      onContextMenu={wrapHandler(onContextMenu, container)}
      onWheel={wrapHandler(onWheel, container)}
      onMouseEnter={hasActiveSelection ? undefined : onPaneMouseEnter}
      onMouseDown={hasActiveSelection ? onMouseDown : undefined}
      onMouseMove={hasActiveSelection ? onMouseMove : onPaneMouseMove}
      onMouseUp={hasActiveSelection ? onMouseUp : undefined}
      onMouseLeave={hasActiveSelection ? onMouseLeave : onPaneMouseLeave}
      ref={container}
      style={containerStyle}
    >
      {children}
      <UserSelection />
    </div>

Once the mouse exits the pane, the onMouseLeave event triggers, ending the selection process. Is there any rationale for not subscribing to the global 'onMouseMove' and 'onMouseUp' events? Additionally, we could consider temporarily disabling text selection globally during the selection process. What do you think?

@hiepnguyen3001
Copy link
Author

I can't think of a reason for not subscribing to the global 'onMouseMove' and 'onMouseUp' events. And yes, I would prefer that text selection is disabled globally during selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants