react-image-crop icon indicating copy to clipboard operation
react-image-crop copied to clipboard

Changing crop activates drag-and-drop layers below image-crop

Open JCQuintas opened this issue 6 years ago • 5 comments

I have a setup where I use a react-image-crop inside a dialog/modal that is over a react-beautiful-dnd list.

Whenever I try to change the crop-area it also activates the drag-and-drop below.

This behavior is fixed by adding an e.stopPropagation when the specific events happen and is what we are using internally to fix this right now. But it might be more interesting to expose all the events to the consumer so he can decide when to stopPropagation or what so ever.

JCQuintas avatar Apr 05 '19 08:04 JCQuintas

Hi @JCQuintas if the event is passed to onDragStart and onDragEnd would this help?

dominictobias avatar Apr 15 '19 17:04 dominictobias

I believe it would help, yes. Though I'm not sure if it would fix my exact issue. If you wish, I can try to setup a demo of the interaction tomorrow.

The version we are using in my company is here. But I pretty much put an e.stopPropagation anywhere an event happened. It might not be necessary though.

JCQuintas avatar Apr 15 '19 19:04 JCQuintas

Passing and event or returning false on dragStart/End doesn't do anything - problem appears when you try to drag an image that is longer than wider.

Inveth avatar Jun 03 '19 13:06 Inveth

@JCQuintas I've applied an temp fix for now that works on all browsers (expecially needed for IE overflowing problem)

getCropImageMaxSize = () => {
    const { offsetWidth = 0, offsetHeight = 0 } = this.reactCropImageContainer || {};
    return {
      width: offsetWidth,
      height: offsetHeight,
    };
  };
 <div
     id="image-crop-container"
     ref={element => {
          this.reactCropImageContainer = element;
           }}>
          <ReactCrop
            src={uploadedImage.file.base64 || ''}
            crop={croppedImage.crop}
            onImageLoaded={image => this.handleReactCropImageLoaded(image)}
            onChange={crop => this.handleReactCropChange(crop)}
            onComplete={cropImage => this.handleReactCropComplete(cropImage)}
            disabled={disabled}
            imageStyle={{
              maxHeight: this.getCropImageMaxSize().height,
              maxWidth: this.getCropImageMaxSize().width,
            }}
            ref={element => {
              this.reactCropImage = element;
            }}
       />
 </div>

Inveth avatar Jun 04 '19 08:06 Inveth

+1

ShaMan123 avatar Jan 02 '21 10:01 ShaMan123