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

fix(ui5-upload-collection): fire drop only when files are dropped within dnd overlay #2527

Merged
merged 2 commits into from
Nov 30, 2020
Merged
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
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we don't document browser events, because they are fired and work anyway. However, we do this for browser events that we modify (such as this one) in order to explain what is different than the expected normal behavior. What you described here is correct, but it would have been correct before the change too. So I'd suggest adding:

<b>Note:</b> The <code>drop</code> event is fired only for the drag and drop overlay and ignored for the other parts of the <code>ui5-upload-collection</code>

or something to this effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* <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