diff --git a/index.js b/index.js index 3f4ff89..03d9df9 100644 --- a/index.js +++ b/index.js @@ -4637,8 +4637,37 @@ username: message jQuery('.ec_style_dropdown_trigger').removeClass('active'); }); - // Menu Item Clicks - jQuery(document).on('click', '.ec_menu_item', function (e) { + // Track touch start position to distinguish taps from scrolls in popup menus + let menuTouchStartY = 0; + let menuTouchStartX = 0; + jQuery(document).on('touchstart', '.ec_popup_menu', function (e) { + const touch = e.originalEvent.touches[0]; + menuTouchStartY = touch.clientY; + menuTouchStartX = touch.clientX; + }); + // Prevent scroll gestures inside a popup menu from bubbling up to .ec_btn and closing the menu + jQuery(document).on('touchend', '.ec_popup_menu', function (e) { + const touch = e.originalEvent.changedTouches[0]; + const deltaY = Math.abs(touch.clientY - menuTouchStartY); + const deltaX = Math.abs(touch.clientX - menuTouchStartX); + if (deltaY > 10 || deltaX > 10) { + e.stopPropagation(); // Scroll — keep menu open + } + }); + + // Menu Item Clicks (touchend added for mobile support) + jQuery(document).on('click touchend', '.ec_menu_item', function (e) { + if (e.type === 'touchend') { + // If the finger moved more than 10px, treat as a scroll — ignore + const touch = e.originalEvent.changedTouches[0]; + const deltaY = Math.abs(touch.clientY - menuTouchStartY); + const deltaX = Math.abs(touch.clientX - menuTouchStartX); + if (deltaY > 10 || deltaX > 10) { + e.stopPropagation(); + return; // Scroll gesture — don't select + } + e.preventDefault(); + } e.stopPropagation(); const parent = jQuery(this).closest('.ec_popup_menu'); const val = jQuery(this).data('val'); diff --git a/manifest.json b/manifest.json index c4e0608..fa5f004 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "js": "index.js", "css": "style.css", "author": "mattjaybe", - "version": "5.0.1", + "version": "5.0.2", "homePage": "https://github.com/mattjaybe/SillyTavern-EchoChamber", "auto_update": true } diff --git a/style.css b/style.css index 4583fb7..52d37b2 100644 --- a/style.css +++ b/style.css @@ -960,9 +960,14 @@ transition: background 0.15s, color 0.15s; } -.ec_menu_item:hover { - background: rgba(255, 255, 255, 0.1); - color: #fff; +/* Only apply hover highlight on devices that support true hover (mouse/trackpad). + On touch-only devices (hover: none) this prevents items from lighting up + while the user scrolls through the menu. */ +@media (hover: hover) { + .ec_menu_item:hover { + background: rgba(255, 255, 255, 0.1); + color: #fff; + } } /* Better selection highlight - subtle and readable */