Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
images: Prevent default browser behavior on paste.
Karl Stolleydf18d2768c11
diff --git a/web/src/upload.js b/web/src/upload.jsindex 5c9c2a24043..203a6d5ae79 100644--- a/web/src/upload.js+++ b/web/src/upload.js@@ -329,6 +329,13 @@ export function setup_upload(config) {const file = item.getAsFile();files.push(file);}+ if (files.length === 0) {+ // Exit when there are no files from the clipboard+ return;+ }+ // Halt the normal browser paste event, which would otherwise+ // present a plain-text version of the file name.+ event.preventDefault();if (config.mode === "compose" && !compose_state.composing()) {compose_actions.respond_to_message({trigger: "file drop or paste"});}diff --git a/web/tests/upload.test.js b/web/tests/upload.test.jsindex c9096aa851c..0e75ff92ae3 100644--- a/web/tests/upload.test.js+++ b/web/tests/upload.test.js@@ -476,6 +476,7 @@ test("copy_paste", ({override, override_rewire}) => {],},},+ preventDefault() {},};let upload_files_called = false;override_rewire(upload, "upload_files", () => {