From 14f03a14a881ed7c5c107132e2922e698e0c41af Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 12 Dec 2017 11:53:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20editor=20and=20drag/drop?= =?UTF-8?q?=20image=20uploads=20in=20IE11=20(#926)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes https://github.com/TryGhost/Ghost/issues/9321 - don't use `dataTransfer.effectAllowed` in IE11 - only fire the action in `{{gh-file-input}}` if there are files selected to prevent a double call to the action due to resetting the input --- ghost/admin/app/components/gh-editor.js | 6 ++++-- ghost/admin/app/components/gh-file-input.js | 6 ++++-- ghost/admin/app/components/gh-file-uploader.js | 6 ++++-- ghost/admin/app/components/gh-image-uploader.js | 6 ++++-- ghost/admin/app/components/gh-profile-image.js | 6 ++++-- .../lib/gh-koenig/addon/components/cards/card-image.js | 6 ++++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ghost/admin/app/components/gh-editor.js b/ghost/admin/app/components/gh-editor.js index 7c1f6538ac..24e7cd2ecb 100644 --- a/ghost/admin/app/components/gh-editor.js +++ b/ghost/admin/app/components/gh-editor.js @@ -89,8 +89,10 @@ export default Component.extend({ // this is needed to work around inconsistencies with dropping files // from Chrome's downloads bar - let eA = event.dataTransfer.effectAllowed; - event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + if (navigator.userAgent.indexOf('Chrome') > -1) { + let eA = event.dataTransfer.effectAllowed; + event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + } event.preventDefault(); event.stopPropagation(); diff --git a/ghost/admin/app/components/gh-file-input.js b/ghost/admin/app/components/gh-file-input.js index 24f5c1d466..7a754e85ba 100644 --- a/ghost/admin/app/components/gh-file-input.js +++ b/ghost/admin/app/components/gh-file-input.js @@ -6,8 +6,10 @@ import XFileInput from 'emberx-file-input/components/x-file-input'; export default XFileInput.extend({ change(e) { let action = this.get('action'); - if (action) { - action(this.files(e), this.resetInput.bind(this)); + let files = this.files(e); + + if (files.length && action) { + action(files, this.resetInput.bind(this)); } }, diff --git a/ghost/admin/app/components/gh-file-uploader.js b/ghost/admin/app/components/gh-file-uploader.js index fd4b0fb0ac..edd9297353 100644 --- a/ghost/admin/app/components/gh-file-uploader.js +++ b/ghost/admin/app/components/gh-file-uploader.js @@ -109,8 +109,10 @@ export default Component.extend({ // this is needed to work around inconsistencies with dropping files // from Chrome's downloads bar - let eA = event.dataTransfer.effectAllowed; - event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + if (navigator.userAgent.indexOf('Chrome') > -1) { + let eA = event.dataTransfer.effectAllowed; + event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + } event.stopPropagation(); event.preventDefault(); diff --git a/ghost/admin/app/components/gh-image-uploader.js b/ghost/admin/app/components/gh-image-uploader.js index 7525f5d840..e3bb45e526 100644 --- a/ghost/admin/app/components/gh-image-uploader.js +++ b/ghost/admin/app/components/gh-image-uploader.js @@ -100,8 +100,10 @@ export default Component.extend({ // this is needed to work around inconsistencies with dropping files // from Chrome's downloads bar - let eA = event.dataTransfer.effectAllowed; - event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + if (navigator.userAgent.indexOf('Chrome') > -1) { + let eA = event.dataTransfer.effectAllowed; + event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + } event.stopPropagation(); event.preventDefault(); diff --git a/ghost/admin/app/components/gh-profile-image.js b/ghost/admin/app/components/gh-profile-image.js index 197043e68d..c6ea5698df 100644 --- a/ghost/admin/app/components/gh-profile-image.js +++ b/ghost/admin/app/components/gh-profile-image.js @@ -62,8 +62,10 @@ export default Component.extend({ // this is needed to work around inconsistencies with dropping files // from Chrome's downloads bar - let eA = event.dataTransfer.effectAllowed; - event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + if (navigator.userAgent.indexOf('Chrome') > -1) { + let eA = event.dataTransfer.effectAllowed; + event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + } event.stopPropagation(); event.preventDefault(); diff --git a/ghost/admin/lib/gh-koenig/addon/components/cards/card-image.js b/ghost/admin/lib/gh-koenig/addon/components/cards/card-image.js index 63c3a020ae..db4d38f11e 100644 --- a/ghost/admin/lib/gh-koenig/addon/components/cards/card-image.js +++ b/ghost/admin/lib/gh-koenig/addon/components/cards/card-image.js @@ -86,8 +86,10 @@ export default Component.extend({ // this is needed to work around inconsistencies with dropping files // from Chrome's downloads bar - let eA = event.dataTransfer.effectAllowed; - event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + if (navigator.userAgent.indexOf('Chrome') > -1) { + let eA = event.dataTransfer.effectAllowed; + event.dataTransfer.dropEffect = (eA === 'move' || eA === 'linkMove') ? 'move' : 'copy'; + } event.stopPropagation(); event.preventDefault();