From 00edd802be402efbec9a11a9ef6559fb15f039ed Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Tue, 30 Jun 2020 14:15:03 +0200 Subject: app-fava: Add patch to fix processing of drag and drop events This is based on [1], modified to act on the packaged JavaScript code. [1] https://github.com/beancount/fava/pull/1123 --- ...-drag-and-drop-events-not-being-processed.patch | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app-fava/patches/app-office/fava-1.15/0001-Fix-drag-and-drop-events-not-being-processed.patch diff --git a/app-fava/patches/app-office/fava-1.15/0001-Fix-drag-and-drop-events-not-being-processed.patch b/app-fava/patches/app-office/fava-1.15/0001-Fix-drag-and-drop-events-not-being-processed.patch new file mode 100644 index 0000000..7eab6ac --- /dev/null +++ b/app-fava/patches/app-office/fava-1.15/0001-Fix-drag-and-drop-events-not-being-processed.patch @@ -0,0 +1,62 @@ +From 4d2817c9915b12b82e26f80f4466e8a6d2da1b1a Mon Sep 17 00:00:00 2001 +From: Wynn Wolf Arbor +Date: Mon, 29 Jun 2020 19:31:30 +0200 +Subject: [PATCH] Fix drag and drop events not being processed + +When uploading documents via drag and drop, we want to make sure that +the DragEvent is only processed if it references dragged files. This is +done by checking the length of the 'event.dataTransfer.files' list. + +In a5eec6d6 (support attaching (already uploaded) documents to txns, +2020-05-16), a check for dragged URLs was added and the validation of +'event.dataTransfer.files' was moved from 'drop()' to 'dragover()'. + +The HTML Living Standard defines a 'drag data store mode' [1], which +governs read and write access to the drag data store. Specifically, if +the drag data store is in protected mode, the 'files' attribute must +return the empty list [2]. + +Before commit a5eec6d6, 'event.dataTransfer.files' was accessed in the +'drop' event, with the drag data store in read-only mode. Now, however, +we access it in the 'dragover' event, with the drag data store in +protected mode. The validation in 'dragover()' therefore fails because +'event.dataTransfer.files' is empty. For browsers that are compliant +with the HTML Living Standard, Fava does not process any drag and drop +events. + +The standard also defines a 'DataTransferItemList' interface [3], whose +'length' attribute [4] can be used to get the number of items in the +drag data store. This is possible even in protected mode, but some +browsers (notably Safari) do not implement this yet [5]. + +Instead, similar to checking for URLs, solve this problem by checking +whether the 'types' list includes entries of type "Files". [6] + +Closes #1122. + +[1] https://html.spec.whatwg.org/multipage/dnd.html#drag-data-store-mode +[2] https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-files +[3] https://html.spec.whatwg.org/multipage/dnd.html#the-datatransferitemlist-interface +[4] https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-length +[5] https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items#Browser_compatibility +[6] https://html.spec.whatwg.org/multipage/dnd.html#concept-datatransfer-types +--- + src/fava/static/app.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/fava/static/app.js b/src/faca/static/app.js +index ce95378..1f35e0b 100644 +--- a/src/fava/static/app.js ++++ b/src/fava/static/app.js +@@ -30325,7 +30325,7 @@ + */ + function dragover(event, closestTarget) { + if (event.dataTransfer && +- (event.dataTransfer.files.length || ++ (event.dataTransfer.types.includes("Files") || + event.dataTransfer.types.includes("text/uri-list"))) { + closestTarget.classList.add("dragover"); + event.preventDefault(); +-- +2.27.0 + -- cgit v1.2.3-2-gb3c3