From 98fb680a921c89d65fb5d85bb4635a80230120c9 Mon Sep 17 00:00:00 2001 From: GCHQ Developer 85297 <95289555+C85297@users.noreply.github.com> Date: Fri, 20 Feb 2026 17:08:11 +0000 Subject: [PATCH] Paste spreadsheets as text (#2200) --- src/web/waiters/InputWaiter.mjs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index 083fb4957..94663a0b2 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -153,16 +153,22 @@ class InputWaiter { paste(event, view) { const clipboardData = event.clipboardData; const items = clipboardData.items; - const files = []; + let files = []; for (let i = 0; i < items.length; i++) { const item = items[i]; - if (item.kind === "file") { - const file = item.getAsFile(); - files.push(file); - - event.preventDefault(); // Prevent the default paste behavior + if (item.kind === "string") { + // If there are any string items they should be preferred over + // files. + files = []; + break; + } else if (item.kind === "file") { + files.push(item.getAsFile()); } } + if (files.length > 0) { + // Prevent the default paste behavior, afterPaste will load the files instead + event.preventDefault(); + } setTimeout(() => { self.afterPaste(files); });