Skip to content

Commit

Permalink
Patch dgg chat stealing focus issue (not a proper fix)
Browse files Browse the repository at this point in the history
This addresses github.com/MemeLabs/Rustla2/issues/117
Not a proper fix, as typing in chat directly after switching will steal a few
characters mid sentence.
Though it's better than nothing, until we can implement a proper fix.
  • Loading branch information
JoannesJ committed Feb 8, 2019
1 parent d4258eb commit bb7fd36
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb7fd36

Please sign in to comment.