From 7ff440a39b6f683a888d622d3790c17f91e6aeec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bok=C5=A1a?= Date: Wed, 16 Apr 2025 20:53:07 +0200 Subject: [PATCH] Fix: prevent default behavior in drag and resize events --- src/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index e4126928..9920e199 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -296,8 +296,8 @@ export class Rnd extends React.PureComponent { } onDragStart(e: RndDragEvent, data: DraggableData) { - if (this.props.onDragStart) { - this.props.onDragStart(e, data); + if (this.props.onDragStart && this.props.onDragStart(e, data) === false) { + return false; } const pos = this.getDraggablePosition(); this.originalPosition = pos; @@ -385,6 +385,9 @@ export class Rnd extends React.PureComponent { dir: ResizeDirection, elementRef: HTMLElement, ) { + if (this.props.onResizeStart && this.props.onResizeStart(e, dir, elementRef) === false) { + return false; + } e.stopPropagation(); this.setState({ resizing: true, @@ -476,9 +479,6 @@ export class Rnd extends React.PureComponent { maxHeight: this.props.maxHeight, }); } - if (this.props.onResizeStart) { - this.props.onResizeStart(e, dir, elementRef); - } } onResize(