summaryrefslogtreecommitdiff
path: root/web/static/js/app.js
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-08-30 20:46:36 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-08-30 20:46:36 +0000
commita17a15966be5db6de423cdcb7c427195102b99d8 (patch)
tree064df43ca46deae246cc1e03dd853b27551a0a4d /web/static/js/app.js
parent533d89befd1fe4b8134440e8d415d40a5fb7c04b (diff)
Fix swipe-nav false positives on scroll, shopping quick-add overflow
Swipe-to-change-tab only ever compared horizontal touch delta against a 50px threshold, with no check against vertical movement -- an ordinary scroll through a long tab (the shopping list, in particular) drifts that far horizontally from natural thumb motion alone, and was getting misread as an intentional swipe. Since timeline sits right before shopping in TAB_ORDER, that's specifically what a rightward drift landed on: "shopping randomly jumps back to timeline." Now requires the horizontal delta to be at least 2x the vertical delta before treating it as a swipe instead of a scroll. Also fixed the shopping tab's inline quick-add row: the store <select> had no width cap, so a long store name could claim enough width to push the Add button past the right edge of the screen -- not just cramped, actually unreachable. Capped the select's width and let the name input actually shrink (needs min-w-0 alongside flex-1, since flex items don't shrink below their content size by default), with flex-wrap as a backstop for anything that still doesn't fit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AwnALZL6bD4VBtATDVv3B
Diffstat (limited to 'web/static/js/app.js')
-rw-r--r--web/static/js/app.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/web/static/js/app.js b/web/static/js/app.js
index 8058dc2..6071ce3 100644
--- a/web/static/js/app.js
+++ b/web/static/js/app.js
@@ -316,7 +316,9 @@ function toggleTask(taskId) {
// Mobile Swipe Navigation
(function() {
let touchStartX = 0;
+ let touchStartY = 0;
let touchEndX = 0;
+ let touchEndY = 0;
const SWIPE_THRESHOLD = 50; // Minimum px for a swipe
// Get ordered list of tab names (main tabs only for swipe)
@@ -324,11 +326,23 @@ function toggleTask(taskId) {
function handleSwipe() {
const swipeDistance = touchEndX - touchStartX;
+ const verticalDistance = touchEndY - touchStartY;
if (Math.abs(swipeDistance) < SWIPE_THRESHOLD) {
return; // Not a significant swipe
}
+ // A normal vertical scroll through a long tab (e.g. the shopping list)
+ // easily drifts 50+ horizontal px over its course from natural thumb
+ // motion -- without comparing against how far the touch moved
+ // vertically, that drift alone was enough to fire a tab change mid-scroll
+ // (reported as "shopping randomly jumps back to timeline", which sits
+ // immediately before it in TAB_ORDER). Require the horizontal component
+ // to clearly dominate before treating it as an intentional swipe.
+ if (Math.abs(swipeDistance) < Math.abs(verticalDistance) * 2) {
+ return;
+ }
+
const currentIndex = TAB_ORDER.indexOf(currentTab);
if (currentIndex === -1) return;
@@ -362,10 +376,12 @@ function toggleTask(taskId) {
tabContent.addEventListener('touchstart', function(e) {
touchStartX = e.changedTouches[0].screenX;
+ touchStartY = e.changedTouches[0].screenY;
}, { passive: true });
tabContent.addEventListener('touchend', function(e) {
touchEndX = e.changedTouches[0].screenX;
+ touchEndY = e.changedTouches[0].screenY;
handleSwipe();
}, { passive: true });
});