diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index 4ff097be..2534809b 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -338,8 +338,18 @@ class Chat { // Visibility document.addEventListener('visibilitychange', debounce(100, () => { this.ishidden = (document['visibilityState'] || 'visible') !== 'visible'; - if (!this.ishidden) focusIfNothingSelected(this); - else ChatMenu.closeMenus(this); + + if (!this.ishidden) { + focusIfNothingSelected(this); + + // Shotgun some focus requests to battle an external focus steal + // github.com/MemeLabs/Rustla2/issues/117 + setTimeout(() => focusIfNothingSelected(this), 1600); + setTimeout(() => focusIfNothingSelected(this), 1800); + setTimeout(() => focusIfNothingSelected(this), 2000); + } else { + ChatMenu.closeMenus(this); + } }), true); // Resize