From 15b5cf7c20bf93b94ff2330b66a48bfd58ce6ed4 Mon Sep 17 00:00:00 2001 From: j433866 Date: Tue, 4 Jun 2019 09:41:47 +0100 Subject: [PATCH] Correctly handle clicking cancel on go to dialog --- src/web/InputWaiter.mjs | 6 +++++- src/web/OutputWaiter.mjs | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/web/InputWaiter.mjs b/src/web/InputWaiter.mjs index 77204b9e..4e15196a 100644 --- a/src/web/InputWaiter.mjs +++ b/src/web/InputWaiter.mjs @@ -1381,7 +1381,11 @@ class InputWaiter { */ async goToTab() { const inputNums = await this.getInputNums(); - const tabNum = parseInt(window.prompt(`Enter tab number (${inputNums.min} - ${inputNums.max}):`, this.getActiveTab().toString()), 10); + let tabNum = window.prompt(`Enter tab number (${inputNums.min} - ${inputNums.max}):`, this.getActiveTab().toString()); + + if (tabNum === null) return; + tabNum = parseInt(tabNum, 10); + this.changeTab(tabNum, this.app.options.syncTabs); } diff --git a/src/web/OutputWaiter.mjs b/src/web/OutputWaiter.mjs index d0907fb5..709e3e37 100755 --- a/src/web/OutputWaiter.mjs +++ b/src/web/OutputWaiter.mjs @@ -797,8 +797,12 @@ class OutputWaiter { */ goToTab() { const min = this.getSmallestInputNum(), - max = this.getLargestInputNum(), - tabNum = parseInt(window.prompt(`Enter tab number (${min} - ${max}):`, this.getActiveTab().toString()), 10); + max = this.getLargestInputNum(); + + let tabNum = window.prompt(`Enter tab number (${min} - ${max}):`, this.getActiveTab().toString()); + if (tabNum === null) return; + tabNum = parseInt(tabNum, 10); + if (this.outputExists(tabNum)) { this.changeTab(tabNum, this.app.options.syncTabs); }