Skip to content

Commit

Permalink
fix(nav): upload of preview images (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelinz authored Oct 1, 2024
1 parent 124b685 commit 4f91fea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions addon/components/category-nav/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export default class CategoryNavCategoryComponent extends Component {
this.dragCounter = 0;
this.isDragOver = false;

if (event.dataTransfer.files.length) {
if (
event.dataTransfer.files.length &&
!event.dataTransfer.getData("text")
) {
return await this.documents.upload(
this.args.category,
event.dataTransfer.files,
Expand All @@ -104,7 +107,7 @@ export default class CategoryNavCategoryComponent extends Component {
documentIds.map(async (id) => {
const document = this.store.peekRecord("document", id);

if (document.category.id === this.args.category.id) {
if (!document || document.category.id === this.args.category.id) {
return true;
}

Expand Down
1 change: 1 addition & 0 deletions addon/components/document-list-item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<div
class="document-thumbnail"
uk-dropdown="pos: right-center; offset: 15; delay-show: 400; delay-hide: 100; container: .alexandria-container;"
{{on "dragstart" (fn (optional @onDragStart) @document)}}
>
<img
data-src="{{@document.thumbnail.value}}"
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/components/category-nav/category-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ module("Integration | Component | category-nav/category", function (hooks) {
await triggerEvent("[data-test-drop]", "drop", {
dataTransfer: {
getData: () => documents.map((d) => d.id).join(","),
files: [],
// sometimes browser send a file as well (e.g. when dragging a thumbnail) - this should be ignored
files: [new File(["Thumbnail"], "test-file.txt")],
},
});

Expand Down Expand Up @@ -91,7 +92,7 @@ module("Integration | Component | category-nav/category", function (hooks) {

await triggerEvent("[data-test-drop]", "drop", {
dataTransfer: {
getData: () => {},
getData: () => "",
files: [new File(["Ember Rules!"], "test-file.txt")],
},
});
Expand Down

0 comments on commit 4f91fea

Please sign in to comment.