From cb6e71d75e526f207b0c4a8f08d660fdde3e7e98 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 12:36:04 -0800 Subject: fix: auto-load more items when pressing 'j' on last item\n\nPreviously, if you were focused on the last loaded item and that item was\nvery long (extending past the viewport), pressing 'j' would do nothing\nbecause there were no more items loaded yet.\n\nNow, when the user presses 'j' and lands on the last item, we automatically\ntrigger loading more items (if available), ensuring that the next 'j' press\nwill work as expected.\n\nAdded test to verify this behavior works correctly. --- frontend/src/components/FeedItems.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'frontend/src/components/FeedItems.tsx') diff --git a/frontend/src/components/FeedItems.tsx b/frontend/src/components/FeedItems.tsx index a058b70..f43852b 100644 --- a/frontend/src/components/FeedItems.tsx +++ b/frontend/src/components/FeedItems.tsx @@ -137,6 +137,13 @@ export default function FeedItems() { } scrollToItem(nextIndex); } + + // If we're now on the last item and there are more items to load, + // trigger loading them so the next 'j' press will work + if (nextIndex === items.length - 1 && hasMore && !loadingMore) { + fetchItems(String(items[items.length - 1]._id)); + } + return nextIndex; }); } else if (e.key === 'k') { @@ -159,7 +166,7 @@ export default function FeedItems() { window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); - }, [items]); + }, [items, hasMore, loadingMore]); -- cgit v1.2.3