Skip to content

remove filter far from search results and add return home button#38

Merged
jamesjohnsdev merged 4 commits into
mainfrom
filterBarClean
Jan 26, 2026
Merged

remove filter far from search results and add return home button#38
jamesjohnsdev merged 4 commits into
mainfrom
filterBarClean

Conversation

@jamesjohnsdev

@jamesjohnsdev jamesjohnsdev commented Jan 26, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a "Home" navigation link with a back arrow icon on author profiles, individual posts, and search pages for convenient navigation back to the home page.
  • Navigation

    • Reorganised the filter navigation routing structure to consolidate and streamline how filter options are accessed throughout the application.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request introduces a new HomeLink UI component and restructures the application's routing hierarchy by consolidating filtered content routes (/, /best, /new) under a parent /_filtered route. The filter bar logic moves from the root layout to the new _filtered layout, and the HomeLink component is integrated across post, author, and search pages to enable quick navigation back to the home page.

Changes

Cohort / File(s) Summary
HomeLink UI Component
apps/client/src/components/ui/home-link/home-link.module.css, apps/client/src/components/ui/home-link/home-link.tsx
New component with styling for inline-flex display, icon and text layout, muted text colour with primary-colour hover state, and smooth transitions. Renders left-arrow icon with "Home" text.
Route Structure Refactoring
apps/client/src/routeTree.gen.ts
Generated route tree updated to reflect new nested route structure with /_filtered as parent route and reorganised FileRoutesByPath, FileRoutesByFullPath, FileRoutesByTo, and FileRoutesById mappings to accommodate the hierarchy.
Layout Restructuring
apps/client/src/routes/__root.tsx, apps/client/src/routes/_filtered.tsx
Root layout stripped of filter bar and navigation-based filter handling. New _filtered layout introduced to centralise filter state management, render FilterBar, and route based on filter selection using useNavigate.
Filtered Route Paths
apps/client/src/routes/_filtered/index.tsx, apps/client/src/routes/_filtered/best.tsx, apps/client/src/routes/_filtered/new.tsx
Routes relocated to _filtered subdirectory with createFileRoute path arguments updated from /, /best, /new to /_filtered/, /_filtered/best, /_filtered/new respectively.
HomeLink Integration
apps/client/src/routes/post/$postid.tsx, apps/client/src/routes/author/$authorid.tsx, apps/client/src/routes/search.tsx
HomeLink component imported and rendered at the top of each route's JSX, providing consistent navigation back to home across detail and search pages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A home link appears with an arrow so bright,
Guiding lost wayfarers back to the light,
Routes nest beneath filtered's welcoming door,
No search page confusion—just organisation galore!
Hop home with a click, where the content feels right! 🏠✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main changes: removing the filter bar from search and adding a home button/link for navigation.
Linked Issues check ✅ Passed All objectives from issue #24 are implemented: filter bar removed from search route, home link component added and integrated into relevant pages.
Out of Scope Changes check ✅ Passed Changes include mention of author profile links not explicitly stated in issue #24 objectives; however, these are minimal additions aligned with navigation improvements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jan 26, 2026

Copy link
Copy Markdown

Deploying hnfeed with  Cloudflare Pages  Cloudflare Pages

Latest commit: cbfa28d
Status: ✅  Deploy successful!
Preview URL: https://d3d81888.hnfeed.pages.dev
Branch Preview URL: https://filterbarclean.hnfeed.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/client/src/routes/_filtered/index.tsx (1)

10-11: Stale TODO comment should be removed.

The TODO mentions replacing placeholder data logic, but useTopStories is already implemented and in use. Consider removing this outdated comment.

🧹 Suggested fix
-//TODO: Get data logic needs to replace placeholder
-//
-
 function RouteComponent() {
apps/client/src/routes/author/$authorid.tsx (1)

51-77: HomeLink is missing from the loading state.

The HomeLink component is rendered at line 81 in the loaded state, but the loading skeleton (lines 51-77) returns early without it. This creates an inconsistent UX where users cannot navigate home while the page is loading.

🛠️ Proposed fix
   if (isLoading) {
     return (
       <div className={style.authorPage}>
+        <HomeLink />
         <div className={style.profileCard}>
🤖 Fix all issues with AI agents
In `@apps/client/src/components/ui/home-link/home-link.tsx`:
- Around line 5-11: The HomeLink component hardcodes the English string "Home";
update HomeLink to use react-i18next instead: import and call useTranslation
inside the HomeLink function, replace the literal span text with the translation
key (e.g., t('home') or a namespaced key like t('common:home')), and keep the
Link, ArrowLeft and style.homeLink usage intact so only the display text changes
to a translated value.

In `@apps/client/src/routes/_filtered.tsx`:
- Around line 9-25: FilteredLayout triggers redundant navigation: remove the
handleFilter navigation flow and let FilterBar's Link-driven MenuItem navigation
be the single source of truth. Delete the handleFilter function and the
useNavigate usage in FilteredLayout, and stop passing the handleChange prop (or
pass a no-op) to FilterBar so navigation occurs only via FilterBar's
Link/MenuItem; update any references to props.handleChange/handleSelect in
FilterBar only if you choose the alternate approach.

Comment on lines +5 to +11
export function HomeLink() {
return (
<Link to="/" className={style.homeLink}>
<ArrowLeft size={16} />
<span>Home</span>
</Link>
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider internationalising the "Home" text.

The string "Home" on line 9 is hardcoded in English. Other components in this codebase (e.g., author/$authorid.tsx) use react-i18next for translations. For consistency, consider using the translation hook.

♻️ Suggested refactor
 import { Link } from '@tanstack/react-router';
 import { ArrowLeft } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
 import style from './home-link.module.css';

 export function HomeLink() {
+  const { t } = useTranslation();
   return (
     <Link to="/" className={style.homeLink}>
       <ArrowLeft size={16} />
-      <span>Home</span>
+      <span>{t('common.home')}</span>
     </Link>
   );
 }
🤖 Prompt for AI Agents
In `@apps/client/src/components/ui/home-link/home-link.tsx` around lines 5 - 11,
The HomeLink component hardcodes the English string "Home"; update HomeLink to
use react-i18next instead: import and call useTranslation inside the HomeLink
function, replace the literal span text with the translation key (e.g.,
t('home') or a namespaced key like t('common:home')), and keep the Link,
ArrowLeft and style.homeLink usage intact so only the display text changes to a
translated value.

Comment on lines +9 to +25
function FilteredLayout() {
const navigate = useNavigate();

function handleFilter(filter: PrimaryFilter) {
if (filter === 'hot') {
navigate({ to: '/' });
} else {
navigate({ to: `/${filter}` });
}
}

return (
<>
<FilterBar handleChange={handleFilter} />
<Outlet />
</>
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat apps/client/src/components/ui/filter-bar/filter-bar.tsx

Repository: nahmanmate/hacker-news

Length of output: 2631


Remove redundant navigation between FilterBar and FilteredLayout.

The FilterBar component has a Link component inside each MenuItem that triggers navigation directly. Additionally, when a MenuItem is selected, handleSelect calls props.handleChange(filter), which invokes handleFilter in FilteredLayout and triggers a second navigate() call. This creates two navigation events for a single user interaction, which could lead to race conditions or unexpected behaviour.

Consider either:

  1. Removing the Link wrapper inside FilterBar's MenuItem and relying solely on handleChange, or
  2. Removing the handleChange callback here and letting FilterBar handle navigation internally via its Link components.
🤖 Prompt for AI Agents
In `@apps/client/src/routes/_filtered.tsx` around lines 9 - 25, FilteredLayout
triggers redundant navigation: remove the handleFilter navigation flow and let
FilterBar's Link-driven MenuItem navigation be the single source of truth.
Delete the handleFilter function and the useNavigate usage in FilteredLayout,
and stop passing the handleChange prop (or pass a no-op) to FilterBar so
navigation occurs only via FilterBar's Link/MenuItem; update any references to
props.handleChange/handleSelect in FilterBar only if you choose the alternate
approach.

@jamesjohnsdev jamesjohnsdev merged commit 7c6831e into main Jan 26, 2026
6 of 7 checks passed
@jamesjohnsdev jamesjohnsdev deleted the filterBarClean branch January 26, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove filter bar from search results & add return to home

1 participant