Skip to content

Commit

Permalink
fix(ui5-upload-collection): fire drop only when files are dropped wit…
Browse files Browse the repository at this point in the history
…hin dnd overlay (#2527)
  • Loading branch information
georgimkv authored Nov 30, 2020
1 parent 5470e23 commit 455f614
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/fiori/src/UploadCollection.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="ui5-uc-root">
<div class="ui5-uc-root" @drop="{{_ondrop}}">
<div class="ui5-uc-header">
<slot name="header"></slot>
</div>
Expand All @@ -24,7 +24,6 @@
@dragenter="{{_ondragenter}}"
@dragleave="{{_ondragleave}}"
@dragover="{{_ondragover}}"
@drop="{{_ondrop}}"
>
<ui5-icon name="upload-to-cloud"></ui5-icon>
<span class="dnd-overlay-text">{{_dndOverlayText}}</span>
Expand Down
16 changes: 16 additions & 0 deletions packages/fiori/src/UploadCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ const metadata = {
},
},
events: /** @lends sap.ui.webcomponents.fiori.UploadCollection.prototype */ {
/**
* Fired when an element is dropped inside the drag and drop overlay.
* <br><br>
* <b>Note:</b> The <code>drop</code> event is fired only when elements are dropped within the drag and drop overlay and ignored for the other parts of the <code>ui5-upload-collection</code>.
*
* @event sap.ui.webcomponents.fiori.UploadCollection#drop
* @readonly
* @param {DataTransfer} dataTransfer The <code>drop</code> event operation data.
* @public
*/
drop: {},

/**
* Fired when the Delete button of any item is pressed.
* <br><br>
Expand Down Expand Up @@ -250,6 +262,10 @@ class UploadCollection extends UI5Element {
return;
}

if (event.target !== this.shadowRoot.querySelector(".uc-dnd-overlay")) {
event.stopPropagation();
}

this._dndOverlayMode = UploadCollectionDnDOverlayMode.None;
}

Expand Down

0 comments on commit 455f614

Please sign in to comment.