From 9e7946ce0474fddb8901df27e5c3646fd87af67c Mon Sep 17 00:00:00 2001
From: Adam Mathes <adam@adammathes.com>
Date: Sun, 15 Feb 2026 08:48:02 -0800
Subject: Make sidebar filters additive by preserving context in links

---
 frontend/src/components/FeedList.tsx | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

(limited to 'frontend/src/components/FeedList.tsx')

diff --git a/frontend/src/components/FeedList.tsx b/frontend/src/components/FeedList.tsx
index fed9196..1ab5246 100644
--- a/frontend/src/components/FeedList.tsx
+++ b/frontend/src/components/FeedList.tsx
@@ -44,7 +44,8 @@ export default function FeedList({
   const handleSearch = (e: React.FormEvent) => {
     e.preventDefault();
     if (searchQuery.trim()) {
-      navigate(`/?q=${encodeURIComponent(searchQuery.trim())}`);
+      const filterPart = currentFilter ? `&filter=${currentFilter}` : '';
+      navigate(`/?q=${encodeURIComponent(searchQuery.trim())}${filterPart}`);
     }
   };
 
@@ -112,17 +113,29 @@ export default function FeedList({
       <div className="filter-section">
         <ul className="filter-list">
           <li className="unread_filter">
-            <Link to="/?filter=unread" className={currentFilter === 'unread' ? 'active' : ''} onClick={handleLinkClick}>
+            <Link
+              to={location.pathname + '?filter=unread'}
+              className={currentFilter === 'unread' ? 'active' : ''}
+              onClick={handleLinkClick}
+            >
               unread
             </Link>
           </li>
           <li className="all_filter">
-            <Link to="/?filter=all" className={currentFilter === 'all' ? 'active' : ''} onClick={handleLinkClick}>
+            <Link
+              to={location.pathname + '?filter=all'}
+              className={currentFilter === 'all' ? 'active' : ''}
+              onClick={handleLinkClick}
+            >
               all
             </Link>
           </li>
           <li className="starred_filter">
-            <Link to="/?filter=starred" className={currentFilter === 'starred' ? 'active' : ''} onClick={handleLinkClick}>
+            <Link
+              to={location.pathname + '?filter=starred'}
+              className={currentFilter === 'starred' ? 'active' : ''}
+              onClick={handleLinkClick}
+            >
               starred
             </Link>
           </li>
@@ -138,7 +151,7 @@ export default function FeedList({
             {tags.map((tag) => (
               <li key={tag.title} className="tag-item">
                 <Link
-                  to={`/tag/${encodeURIComponent(tag.title)}`}
+                  to={`/tag/${encodeURIComponent(tag.title)}${currentFilter ? `?filter=${currentFilter}` : ''}`}
                   className={`tag-link ${tagName === tag.title ? 'active' : ''}`}
                   onClick={handleLinkClick}
                 >
@@ -162,7 +175,7 @@ export default function FeedList({
               {feeds.map((feed) => (
                 <li key={feed._id} className="sidebar-feed-item">
                   <Link
-                    to={`/feed/${feed._id}`}
+                    to={`/feed/${feed._id}${currentFilter ? `?filter=${currentFilter}` : ''}`}
                     className={`feed-title ${feedId === String(feed._id) ? 'active' : ''}`}
                     onClick={handleLinkClick}
                   >
-- 
cgit v1.2.3

