Skip to content

Commit 3bb4b05

Browse files
authored
Close the menu on second click. (#5110)
1 parent e4d724e commit 3bb4b05

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

js/main.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,17 @@ for (i = 0; i < slimDropdownElements.length; i++) {
193193
var buttonsInChat = document.querySelectorAll("#chat-tab:not(.old-ui) #chat-buttons button");
194194
var button = document.getElementById("hover-element-button");
195195
var menu = document.getElementById("hover-menu");
196+
var istouchscreen = (navigator.maxTouchPoints > 0) || "ontouchstart" in document.documentElement;
196197

197198
function showMenu() {
198199
menu.style.display = "flex"; // Show the menu
199200
}
200201

201202
function hideMenu() {
202203
menu.style.display = "none"; // Hide the menu
203-
document.querySelector("#chat-input textarea").focus();
204+
if (!istouchscreen) {
205+
document.querySelector("#chat-input textarea").focus(); // Focus on the chat input
206+
}
204207
}
205208

206209
if (buttonsInChat.length > 0) {
@@ -235,11 +238,18 @@ function isMouseOverButtonOrMenu() {
235238
}
236239

237240
button.addEventListener("mouseenter", function () {
238-
showMenu();
241+
if (!istouchscreen) {
242+
showMenu();
243+
}
239244
});
240245

241246
button.addEventListener("click", function () {
247+
if (menu.style.display === "flex") {
248+
hideMenu();
249+
}
250+
else {
242251
showMenu();
252+
}
243253
});
244254

245255
// Add event listener for mouseleave on the button

0 commit comments

Comments
 (0)