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

Cancel drop #610

Open
danielbattat opened this issue Jan 31, 2024 · 2 comments
Open

Cancel drop #610

danielbattat opened this issue Jan 31, 2024 · 2 comments

Comments

@danielbattat
Copy link

Is your feature request related to a problem? Please describe.
When a user moves their mouse outside of the canvas, the last "touched" point in the canvas is where the element will drop when the mouse is released, even if the mouse is outside the canvas. There are times when a user changes their mind re dragging. It would be intuitive, IMO, to have the drag cancel when the mouse is outside of the canvas, especially, if the drag is to create a new element, and then the user moves the element "back" into the toolbox. It will still drop into the last touched place on the canvas

Describe the solution you'd like
A way to cancel the drag action if over a certain area, or outside the canvas

Additional context
Add any other context or screenshots about the feature request here.

@danielbattat
Copy link
Author

I worked around this by making the background area around the droppable area also a canvas, but with rule: canMoveIn => false. It works but I think there should be a better way.

@jamime
Copy link

jamime commented Mar 10, 2024

I found you can customise the events https://craft.js.org/docs/api/editor#override-default-event-handlers

I tried using setIndicator(null) and clearEvents(), but neither worked. Even when pressing the ESC key, the component is dropped to the last indicator position.

If the indicator is false, the drop is canceled - however, this comes directly from the positioner and not from the editor store.

https://github.com/prevwong/craft.js/blob/05ce87535047e9fa75d30b0627450ad00d0bc16d/packages/core/src/events/DefaultEventHandlers.ts#L364C1-L366C6

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

3 participants