Skip to content

feat/move-main-page-search-bar#4105

Open
nios-x wants to merge 1 commit intoOWASP:mainfrom
nios-x:feat/move-main-page-search-bar
Open

feat/move-main-page-search-bar#4105
nios-x wants to merge 1 commit intoOWASP:mainfrom
nios-x:feat/move-main-page-search-bar

Conversation

@nios-x
Copy link
Contributor

@nios-x nios-x commented Feb 27, 2026

Proposed change

Resolves #4087

This PR completes the migration of the main page search into the global navigation bar and improves search clarity across scoped pages. The update ensures a consistent, accessible, and non-redundant search experience while clearly distinguishing between:

  • Global search (available in the header)
  • Page-scoped search (Chapters, Projects, Members, etc.)

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Walkthrough

This PR moves the search functionality from the home page to the global navigation header, making search accessible across all pages. It adds scope labels to page-specific searches to provide context, removes the redundant home page search bar, and introduces UI customization props for the MultiSearchBar component to support both mobile and desktop layouts.

Changes

Cohort / File(s) Summary
Search Scope Labels
frontend/src/app/chapters/page.tsx, frontend/src/app/committees/page.tsx, frontend/src/app/contribute/page.tsx, frontend/src/app/members/page.tsx, frontend/src/app/mentorship/programs/page.tsx, frontend/src/app/my/mentorship/page.tsx, frontend/src/app/organizations/page.tsx, frontend/src/app/projects/page.tsx
Added scopeLabel prop to SearchPageLayout in each page to provide contextual search scope descriptions (e.g., "Search within chapters").
Home Page Cleanup
frontend/src/app/page.tsx
Removed MultiSearchBar import and its JSX usage, consolidating search to the global navigation.
Header Global Search
frontend/src/components/Header.tsx
Added mobile and desktop search experiences with new state management (mobileSearchOpen), toggle logic coordinating menu and search visibility, resize handling, outside-click detection, and dedicated search button for small screens. MultiSearchBar now rendered persistently in header for lg+ viewports and conditionally for mobile via modal overlay.
Search Customization
frontend/src/components/MultiSearch.tsx, frontend/src/types/search.ts
Extended MultiSearchBar with optional props: autoFocus, containerClassName, inputClassName for UI flexibility. Implemented autoFocus via useEffect and composed classNames using cn utility.
SearchPageLayout Enhancement
frontend/src/components/SearchPageLayout.tsx
Added optional scopeLabel prop to display a contextual label above the search bar, with conditional rendering and styling when provided.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

frontend, frontend-tests

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat/move-main-page-search-bar' accurately reflects the core change: moving the main page search bar to the global navigation, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all key requirements from #4087: global search added to Header, page-specific search clarity improved via scopeLabel props, main page search removed, and responsive mobile search UI implemented.
Out of Scope Changes check ✅ Passed All changes are directly aligned with #4087 objectives. The modifications to MultiSearchBar props and SearchPageLayout are necessary supporting changes for implementing the feature.
Description check ✅ Passed The pull request description directly addresses the changeset by explaining how the main page search bar has been moved into the global navigation bar, aligning with the provided file-level changes.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (2)
frontend/src/components/MultiSearch.tsx (1)

166-166: ⚠️ Potential issue | 🟡 Minor

Missing showSuggestions in dependency array.

The handleKeyDown function references showSuggestions (line 123), but it's not included in the useEffect dependency array. This could cause stale closure issues where the handler doesn't react to showSuggestions changes correctly.

🔧 Proposed fix
-  }, [searchQuery, suggestions, highlightedIndex, handleSuggestionClick])
+  }, [searchQuery, suggestions, highlightedIndex, handleSuggestionClick, showSuggestions])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/MultiSearch.tsx` at line 166, The effect that
registers the keyboard handler uses handleKeyDown which reads showSuggestions
but showSuggestions is missing from the dependency array; update the useEffect
in the MultiSearch component to include showSuggestions alongside searchQuery,
suggestions, highlightedIndex, and handleSuggestionClick (or alternatively
recreate/register handleKeyDown inside the effect) so the handler never captures
a stale showSuggestions value.
frontend/src/components/Header.tsx (1)

76-76: ⚠️ Potential issue | 🟠 Major

Missing mobileSearchOpen in dependency array.

The handleOutsideClick function references mobileSearchOpen (line 59), but only mobileMenuOpen is in the dependency array. This will cause stale closure issues where outside clicks won't correctly close the mobile search panel.

🔧 Proposed fix
-  }, [mobileMenuOpen])
+  }, [mobileMenuOpen, mobileSearchOpen])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/Header.tsx` at line 76, The useEffect that registers
handleOutsideClick currently lists only mobileMenuOpen in its dependency array,
but handleOutsideClick reads mobileSearchOpen, which can cause stale closures;
update the dependency array for the effect that registers handleOutsideClick to
include mobileSearchOpen (in addition to mobileMenuOpen) so the handler sees the
latest mobileSearchOpen state, or alternatively memoize handleOutsideClick with
useCallback using [mobileMenuOpen, mobileSearchOpen] and then use that stable
callback in the effect.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@frontend/src/components/Header.tsx`:
- Line 76: The useEffect that registers handleOutsideClick currently lists only
mobileMenuOpen in its dependency array, but handleOutsideClick reads
mobileSearchOpen, which can cause stale closures; update the dependency array
for the effect that registers handleOutsideClick to include mobileSearchOpen (in
addition to mobileMenuOpen) so the handler sees the latest mobileSearchOpen
state, or alternatively memoize handleOutsideClick with useCallback using
[mobileMenuOpen, mobileSearchOpen] and then use that stable callback in the
effect.

In `@frontend/src/components/MultiSearch.tsx`:
- Line 166: The effect that registers the keyboard handler uses handleKeyDown
which reads showSuggestions but showSuggestions is missing from the dependency
array; update the useEffect in the MultiSearch component to include
showSuggestions alongside searchQuery, suggestions, highlightedIndex, and
handleSuggestionClick (or alternatively recreate/register handleKeyDown inside
the effect) so the handler never captures a stale showSuggestions value.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5d3d6a and c0b6c7e.

📒 Files selected for processing (13)
  • frontend/src/app/chapters/page.tsx
  • frontend/src/app/committees/page.tsx
  • frontend/src/app/contribute/page.tsx
  • frontend/src/app/members/page.tsx
  • frontend/src/app/mentorship/programs/page.tsx
  • frontend/src/app/my/mentorship/page.tsx
  • frontend/src/app/organizations/page.tsx
  • frontend/src/app/page.tsx
  • frontend/src/app/projects/page.tsx
  • frontend/src/components/Header.tsx
  • frontend/src/components/MultiSearch.tsx
  • frontend/src/components/SearchPageLayout.tsx
  • frontend/src/types/search.ts
💤 Files with no reviewable changes (1)
  • frontend/src/app/page.tsx

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 13 files

Confidence score: 3/5

  • There’s some user-facing risk: moving MultiSearchBar to a global header can drop event search results because it no longer receives eventData from the page query in frontend/src/app/page.tsx.
  • AutoFocus can fail to trigger after load because the effect in frontend/src/components/MultiSearch.tsx doesn’t re-run when isLoaded flips, so the input may never get focus.
  • Pay close attention to frontend/src/app/page.tsx, frontend/src/components/MultiSearch.tsx - search data wiring and focus timing depend on mount/load order.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/src/app/page.tsx">

<violation number="1" location="frontend/src/app/page.tsx:149">
P1: Event search functionality will be lost when MultiSearchBar is moved to global Header. The component relies on `eventData={data?.upcomingEvents ?? []}` from page-specific GraphQL query, but the relocated component in Header.tsx does not receive this prop. Since events are not in the Algolia `indexes` array, search will silently return no event results.</violation>
</file>

<file name="frontend/src/components/MultiSearch.tsx">

<violation number="1" location="frontend/src/components/MultiSearch.tsx:182">
P1: The autoFocus feature fails when the component mounts with `isLoaded=false`. The useEffect only depends on `[autoFocus]` but the input element is conditionally rendered based on `isLoaded`. When `isLoaded` becomes `true`, the effect won't re-run because `autoFocus` hasn't changed, leaving the input unfocused.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

/>
</div>
</div>
<SecondaryCard
Copy link
Contributor

Choose a reason for hiding this comment

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

P1: Event search functionality will be lost when MultiSearchBar is moved to global Header. The component relies on eventData={data?.upcomingEvents ?? []} from page-specific GraphQL query, but the relocated component in Header.tsx does not receive this prop. Since events are not in the Algolia indexes array, search will silently return no event results.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/app/page.tsx, line 149:

<comment>Event search functionality will be lost when MultiSearchBar is moved to global Header. The component relies on `eventData={data?.upcomingEvents ?? []}` from page-specific GraphQL query, but the relocated component in Header.tsx does not receive this prop. Since events are not in the Algolia `indexes` array, search will silently return no event results.</comment>

<file context>
@@ -146,14 +145,6 @@ export default function Home() {
-            />
-          </div>
         </div>
         <SecondaryCard
           icon={FaCalendarAlt}
</file context>

Comment on lines +182 to +185
useEffect(() => {
if (autoFocus) {
inputRef.current?.focus()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

P1: The autoFocus feature fails when the component mounts with isLoaded=false. The useEffect only depends on [autoFocus] but the input element is conditionally rendered based on isLoaded. When isLoaded becomes true, the effect won't re-run because autoFocus hasn't changed, leaving the input unfocused.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/MultiSearch.tsx, line 182:

<comment>The autoFocus feature fails when the component mounts with `isLoaded=false`. The useEffect only depends on `[autoFocus]` but the input element is conditionally rendered based on `isLoaded`. When `isLoaded` becomes `true`, the effect won't re-run because `autoFocus` hasn't changed, leaving the input unfocused.</comment>

<file context>
@@ -173,6 +179,12 @@ const MultiSearchBar: React.FC<MultiSearchBarProps> = ({
     }
   }, [])
 
+  useEffect(() => {
+    if (autoFocus) {
+      inputRef.current?.focus()
</file context>
Suggested change
useEffect(() => {
if (autoFocus) {
inputRef.current?.focus()
}
useEffect(() => {
if (autoFocus && isLoaded) {
inputRef.current?.focus()
}
}, [autoFocus, isLoaded])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move Main Page Search Bar to Global Navigation Bar and Simplify Search UI/UX

1 participant