Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/main/src/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,9 @@ class Dialog extends Popup {
}

_handleDragStart(e: DragEvent) {
if (this.draggable) {
// Only prevent native drag behavior when dragging from the header
// to allow native drag-and-drop functionality in the dialog content.
if (this.draggable && e.target instanceof HTMLElement && Dialog._isHeader(e.target)) {
e.preventDefault();
}
}
Expand Down
33 changes: 33 additions & 0 deletions packages/main/test/pages/Dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,22 @@
<br>
<ui5-button id="multiple-show">Open dialog calling show() multiple times</ui5-button>

<br>
<br>
<ui5-button id="native-dnd-open">Open draggable dialog with native DnD</ui5-button>

<ui5-block-layer></ui5-block-layer>

<ui5-dialog id="native-dnd-dialog" header-text="Draggable Dialog with Native DnD" draggable>
<p>Drag items to drop zone:</p>
<div id="dnd-item-1" draggable="true">Item 1</div>
<div id="dnd-item-2" draggable="true">Item 2</div>
<div id="drop-zone">Drop Zone</div>
<div slot="footer" class="dialogFooter">
<ui5-button id="native-dnd-close">Close</ui5-button>
</div>
</ui5-dialog>

<ui5-dialog id="msg-dialog" header-text="Message dialog" class="dialog1auto">
<p>Build enterprise-ready web applications, responsive to all devices and running on the browser of your choice.
That´s OpenUI5.</p>
Expand Down Expand Up @@ -805,6 +819,25 @@
window["dialogFocus1"].close();
});

window["native-dnd-open"].addEventListener("click", () => window["native-dnd-dialog"].open = true);
window["native-dnd-close"].addEventListener("click", () => window["native-dnd-dialog"].open = false);

document.getElementById("dnd-item-1").addEventListener("dragstart", (e) => {
e.dataTransfer.setData("text", "item-1");
});

document.getElementById("dnd-item-2").addEventListener("dragstart", (e) => {
e.dataTransfer.setData("text", "item-2");
});

const dropZone = document.getElementById("drop-zone");
dropZone.addEventListener("dragover", (e) => e.preventDefault());
dropZone.addEventListener("drop", (e) => {
e.preventDefault();
const data = e.dataTransfer.getData("text");
dropZone.textContent = `Dropped: ${data}`;
});

</script>
</body>

Expand Down
Loading