summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaladox none <thomasmulhall410@yahoo.com>2021-06-30 00:28:16 +0000
committerPaladox none <thomasmulhall410@yahoo.com>2021-07-01 13:38:45 +0000
commitdf150be0e7910dab47424b049b2b742c2de11204 (patch)
treed9649a99b5b935c426fcc9ea7979a335dbf663f0
parentfc8e4ea1f19934d4a1f1d1120e421359ac7c6f0d (diff)
Fix drag and drop
Fixes an issue where trying to drop a file into the drop box did not work. Instead it just opened the file in a separate tab instead of uploading. Also add support for uploading multiple files (only supported when dragging files in). Change-Id: Ib9d1cce7fb3bbc39f0a39fc3568138a6e9d59e90 (cherry picked from commit 39eb8dc656f909a1743d523f84a79ed90f66cad9)
-rw-r--r--polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js5
-rw-r--r--polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_html.js18
2 files changed, 18 insertions, 5 deletions
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
index 7ca849fed1..67357c456c 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
@@ -302,6 +302,11 @@ class GrEditControls extends mixinBehaviors( [
fr.readAsDataURL(file);
}
}
+
+ _handleKeyPress(event) {
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ }
}
customElements.define(GrEditControls.is, GrEditControls);
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_html.js b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_html.js
index 02639c063c..73487de7fd 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_html.js
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_html.js
@@ -95,21 +95,29 @@ export const htmlTemplate = html`
query="[[_query]]"
text="{{_path}}"
></gr-autocomplete>
- <div id="dragDropArea" on-drop="_handleDragAndDropUpload">
- <p>Drag and drop a file here</p>
- <p>or</p>
- <p>
+ <div
+ id="dragDropArea"
+ contenteditable="true"
+ on-drop="_handleDragAndDropUpload"
+ on-keypress="_handleKeyPress"
+ >
+ <p contenteditable="false">Drag and drop a file here</p>
+ <p contenteditable="false">or</p>
+ <p contenteditable="false">
<iron-input>
<input
is="iron-input"
id="fileUploadInput"
type="file"
on-change="_handleFileUploadChanged"
+ multiple
hidden
/>
</iron-input>
<label for="fileUploadInput">
- <gr-button id="fileUploadBrowse">Browse</gr-button>
+ <gr-button id="fileUploadBrowse" contenteditable="false"
+ >Browse</gr-button
+ >
</label>
</p>
</div>