From d9f8f45169df7b17ac011a4d3e721b310bd6706d Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 19 Dec 2019 13:02:21 +0000 Subject: [PATCH] Make sure channel exists. --- client/js/keybinds.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/js/keybinds.js b/client/js/keybinds.js index fc7a1fa8..91f069ed 100644 --- a/client/js/keybinds.js +++ b/client/js/keybinds.js @@ -97,11 +97,13 @@ Mousetrap.bind(["alt+a"], function() { function jumpToChannel(targetChannel) { switchToChannel(targetChannel); - scrollIntoViewNicely( - document.querySelector( - `#sidebar .channel-list-item[aria-controls="#chan-${targetChannel.id}"]` - ) + const element = document.querySelector( + `#sidebar .channel-list-item[aria-controls="#chan-${targetChannel.id}"]` ); + + if (element) { + scrollIntoViewNicely(element); + } } // Ignored keys which should not automatically focus the input bar