diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-15 08:48:02 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-15 08:48:02 -0800 |
| commit | 9e7946ce0474fddb8901df27e5c3646fd87af67c (patch) | |
| tree | 255cf49251d238b699cb1bd62ee28c2efeddf5c0 /frontend/src | |
| parent | ea5d89b47a5424fc81e99934183c0ad7a0cf2426 (diff) | |
| download | neko-9e7946ce0474fddb8901df27e5c3646fd87af67c.tar.gz neko-9e7946ce0474fddb8901df27e5c3646fd87af67c.tar.bz2 neko-9e7946ce0474fddb8901df27e5c3646fd87af67c.zip | |
Make sidebar filters additive by preserving context in links
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/components/FeedList.tsx | 25 | ||||
| -rw-r--r-- | frontend/src/components/TagView.test.tsx | 2 |
2 files changed, 20 insertions, 7 deletions
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} > diff --git a/frontend/src/components/TagView.test.tsx b/frontend/src/components/TagView.test.tsx index 16fdee7..de0a318 100644 --- a/frontend/src/components/TagView.test.tsx +++ b/frontend/src/components/TagView.test.tsx @@ -53,7 +53,7 @@ describe('Tag View Integration', () => { // Verify structure const techTag = screen.getByText('News').closest('a'); - expect(techTag).toHaveAttribute('href', '/tag/News'); + expect(techTag).toHaveAttribute('href', '/tag/News?filter=unread'); }); it('fetches items by tag in FeedItems', async () => { |
