From 9f7ef209fad9e51714021902673ef24a2c64d086 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 16 Jun 2024 11:36:15 -0600 Subject: [PATCH] fix: chatlist --- src/lib/components/layout/Sidebar.svelte | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 8b4c5664e..73ce2b33d 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -120,18 +120,31 @@ } }; - document.addEventListener('keydown', onKeyDown); - document.addEventListener('keyup', onKeyUp); + const onFocus = () => {}; + + const onBlur = () => { + shiftKey = false; + selectedChatId = false; + }; + + window.addEventListener('keydown', onKeyDown); + window.addEventListener('keyup', onKeyUp); window.addEventListener('touchstart', onTouchStart); window.addEventListener('touchend', onTouchEnd); + window.addEventListener('focus', onFocus); + window.addEventListener('blur', onBlur); + return () => { window.removeEventListener('keydown', onKeyDown); window.removeEventListener('keyup', onKeyUp); window.removeEventListener('touchstart', onTouchStart); window.removeEventListener('touchend', onTouchEnd); + + window.removeEventListener('focus', onFocus); + window.removeEventListener('blur', onBlur); }; });