Focus the chat whenever a button is pressed anywhere
parent
d446869a28
commit
20fecd6891
|
@ -43,6 +43,15 @@ export const setupChat = async (socket) => {
|
||||||
document.querySelector("#chatbox-container").style["display"] = "block";
|
document.querySelector("#chatbox-container").style["display"] = "block";
|
||||||
setupChatboxEvents(socket);
|
setupChatboxEvents(socket);
|
||||||
|
|
||||||
|
window.addEventListener("keydown", event => {
|
||||||
|
try {
|
||||||
|
const isSelectionEmpty = window.getSelection().toString().length === 0;
|
||||||
|
if (event.code.match(/Key\w/) && isSelectionEmpty)
|
||||||
|
document.querySelector("#chatbox-send > input").focus()
|
||||||
|
} catch (_err) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fixChatSize();
|
fixChatSize();
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
fixChatSize();
|
fixChatSize();
|
||||||
|
|
Loading…
Reference in New Issue