-
Hi there! I'm writing an app where users can drag custom components onto the canvas (not using the blocks manager, the components are dragged from elsewhere). I followed the advice by @artf read here: #2595 And it works great, the component is added to the canvas as expected. However I want to apply some logic before actually adding the component to the canvas: when the user drops it at the desired location, I want to show a dialog offering to choose among a list of different components (variations of the initially dragged one). When the user selects an option in this dialog, then I'll finally add the chosen component to the canvas. What's the best approach for this? I've (roughly) succeeded at this by calling the browser's native "prompt()" function inside the "canvas:dragdata" callback function. Calling prompt() seems to effectively pause execution so I can change the value of result.content as needed. But I need a better UI for this dialog, so using prompt() is not an actual solution. Based on this, I've also tried setting the callback function as async, but it does not work (the original "" element is added to the canvas before the user chooses an option in the dialog. Here's the two code examples:
Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @protozoo I'd suggest creating and dropping a placeholder kind of component, once the user decides and confirm the type you can remove the placeholder and drop, at the same position, the proper one. |
Beta Was this translation helpful? Give feedback.
Hi @protozoo I'd suggest creating and dropping a placeholder kind of component, once the user decides and confirm the type you can remove the placeholder and drop, at the same position, the proper one.