From 06589c782994d8233e29c01742ac69c361c0d0aa Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Mon, 18 Sep 2023 14:08:30 +0200 Subject: [PATCH] minor TS type fixes --- frontend/components/Editor.js | 8 ++++---- frontend/components/SelectionArea.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/components/Editor.js b/frontend/components/Editor.js index 50f4326a71..99bcc2369f 100644 --- a/frontend/components/Editor.js +++ b/frontend/components/Editor.js @@ -1185,13 +1185,13 @@ patch: ${JSON.stringify( // if (e.defaultPrevented) { // return // } - if (e.key.toLowerCase() === "q" && has_ctrl_or_cmd_pressed(e)) { + if (e.key?.toLowerCase() === "q" && has_ctrl_or_cmd_pressed(e)) { // This one can't be done as cmd+q on mac, because that closes chrome - Dral if (Object.values(this.state.notebook.cell_results).some((c) => c.running || c.queued)) { this.actions.interrupt_remote() } e.preventDefault() - } else if (e.key.toLowerCase() === "s" && has_ctrl_or_cmd_pressed(e)) { + } else if (e.key?.toLowerCase() === "s" && has_ctrl_or_cmd_pressed(e)) { const some_cells_ran = this.actions.set_and_run_all_changed_remote_cells() if (!some_cells_ran) { // all cells were in sync allready @@ -1239,8 +1239,8 @@ patch: ${JSON.stringify( } if (this.state.disable_ui && this.state.backend_launch_phase === BackendLaunchPhase.wait_for_user) { - // const code = e.key.charCodeAt(0) - if (e.key === "Enter" || e.key.length === 1) { + // const code = e.key?.charCodeAt(0) + if (e.key === "Enter" || e.key?.length === 1) { if (!document.body.classList.contains("wiggle_binder")) { document.body.classList.add("wiggle_binder") setTimeout(() => { diff --git a/frontend/components/SelectionArea.js b/frontend/components/SelectionArea.js index 7f145bb7dd..eb705ad324 100644 --- a/frontend/components/SelectionArea.js +++ b/frontend/components/SelectionArea.js @@ -151,7 +151,7 @@ export const SelectionArea = ({ on_selection, set_scroller, cell_order }) => { // Ctrl+A to select all cells const onkeydown = (e) => { - if (e.key.toLowerCase() === "a" && has_ctrl_or_cmd_pressed(e)) { + if (e.key?.toLowerCase() === "a" && has_ctrl_or_cmd_pressed(e)) { // if you are not writing text somewhere else if (document.activeElement === document.body && (window.getSelection()?.isCollapsed ?? true)) { on_selection(cell_order)