From 001220cfcaa5ee3b5b58f192804690bbeed9bbaf Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Fri, 29 Mar 2024 16:27:04 +0100 Subject: [PATCH] Fix cell copying on Firefox (#2869) --- .github/workflows/TypeScriptCheck.yml | 4 ++-- frontend/components/Editor.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/TypeScriptCheck.yml b/.github/workflows/TypeScriptCheck.yml index fce836337d..83c99083be 100644 --- a/.github/workflows/TypeScriptCheck.yml +++ b/.github/workflows/TypeScriptCheck.yml @@ -24,9 +24,9 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "18.x" + node-version: "21.x" - - run: npm install typescript@5.0.4 -g + - run: npm install typescript@5.4.3 -g - run: npm install working-directory: frontend diff --git a/frontend/components/Editor.js b/frontend/components/Editor.js index 79795111aa..efe48c6bc5 100644 --- a/frontend/components/Editor.js +++ b/frontend/components/Editor.js @@ -1320,10 +1320,14 @@ patch: ${JSON.stringify( if (!in_textarea_or_input()) { const serialized = this.serialize_selected() if (serialized) { - navigator.clipboard.writeText(serialized).catch((err) => { - console.error("Error copying cells", e, err) - alert(`Error copying cells: ${err?.message ?? err}`) - }) + e.preventDefault() + // wait one frame to get transient user activation + requestAnimationFrame(() => + navigator.clipboard.writeText(serialized).catch((err) => { + console.error("Error copying cells", e, err, navigator.userActivation) + alert(`Error copying cells: ${err?.message ?? err}`) + }) + ) } } })