v.5.0.2 - Fixed menus on mobile

- Fixed issue with menu options weren't tappable on mobile
This commit is contained in:
mattjaybe 2026-02-27 15:46:00 -05:00 committed by GitHub
parent 5fae5b4572
commit a65b60ab29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 6 deletions

View file

@ -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');

View file

@ -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
}

View file

@ -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 */