Skip to content

[UI/UX] Refactor Navbar for Improved Visual Hierarchy and Responsive Design#73

Merged
kunalverma2512 merged 2 commits into
kunalverma2512:mainfrom
Aish-kul16:refactor/navbar-ui
May 17, 2026
Merged

[UI/UX] Refactor Navbar for Improved Visual Hierarchy and Responsive Design#73
kunalverma2512 merged 2 commits into
kunalverma2512:mainfrom
Aish-kul16:refactor/navbar-ui

Conversation

@Aish-kul16
Copy link
Copy Markdown
Contributor

@Aish-kul16 Aish-kul16 commented May 17, 2026

Refactored the navbar UI/UX to improve visual hierarchy, spacing consistency, readability, and responsive behavior while preserving the project's brutalist design language and all existing functionality.

  • Improvements Made
  1. Visual Hierarchy
  • Improved distinction between primary and secondary actions
  • Reduced visual competition between navigation elements
  • Refined typography hierarchy and spacing rhythm
  1. Layout & Spacing
  • Improved navbar spacing and alignment consistency
  • Added better breathing room between navigation items
  • Refined grouping of profile and action controls
  1. UI/UX Enhancements
  • Reduced unnecessary visual clutter
  • Refined brutalist styling without changing project identity
  • Improved hover and interaction states
  • Cleaner mega menu structure and readability
  1. Responsive Improvements
  • Improved mobile navigation structure
  • Better spacing and usability across breakpoints
  • Refined mobile menu interactions and layout behavior
  • Technical Notes
  • Preserved all existing functionality and routing
  • Maintained accessibility considerations
  • Kept reusable and scalable component structure intact
  • No backend or authentication logic modified
  • Screenshots

  • Before

Screenshot 2026-05-17 161220

-After

Screenshot 2026-05-17 163529

Closes #57

Summary by CodeRabbit

  • Style

    • Redesigned navigation bar layout and visual styling for desktop and mobile
    • Restyled center links and right-side CTA/auth area, including refreshed “APEX” CTA
    • Mobile hamburger row and menu visuals overhauled; chevron/tag badges added
  • New Features

    • Initials-based identity chip added alongside display name
    • Mobile “Tools” becomes an accordion with nested submenu expansion
  • Bug Fixes / Improvements

    • Escape key and outside-click now close menus; hover uses intent timeouts
    • Mobile menu auto-closes on route changes

Review Change Stack

@github-actions
Copy link
Copy Markdown

🚀 PR Received Successfully

Hello @Aish-kul16,

Thank you for taking the initiative to contribute to this project.

Please ensure that your PR follows all project guidelines properly before requesting review.

⚠️ Important Instructions

  • Maintain proper code quality and structure
  • Do not make unnecessary changes/files
  • Ensure responsiveness across devices
  • Follow existing project conventions strictly
  • Attach screenshots/videos for UI-related changes
  • Resolve merge conflicts before requesting review
  • Avoid AI-generated low quality PRs or copied implementations

📌 Mandatory for GSSoC'26 Participants

Joining the community group and announcement channel is compulsory for all contributors participating through GSSoC'26.

Failure to follow contribution guidelines may lead to PR rejection.

We appreciate your effort and wish you a great open-source journey ahead. ✨

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82c47954-5062-45d1-b3f8-3f217d50d129

📥 Commits

Reviewing files that changed from the base of the PR and between eec9c4e and 9b512e9.

📒 Files selected for processing (1)
  • frontend/src/components/shared/Navbar.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/shared/Navbar.jsx

📝 Walkthrough

Walkthrough

Navbar.jsx is refactored to componentize the Tools mega menu (Tag, Chevron, MegaMenuPanel), consolidate state/keyboard/hover handlers, update user identity chip, and restyle/rewire desktop and mobile navbar rendering and interactions.

Changes

Navbar Mega Menu & Layout Refactor

Layer / File(s) Summary
Mega Menu components
frontend/src/components/shared/Navbar.jsx
Adds TAG_COLORS, Tag, Chevron, and MegaMenuPanel to render the desktop Tools mega dropdown with submenu grid and Escape handling.
State & event handlers
frontend/src/components/shared/Navbar.jsx
Closes mobile menu on route pathname changes, introduces cleanup for mega-menu leave timeout, and refactors handlers (handleLogout, toggleMenu, closeMenu, hover intent enter/leave).
Desktop rendering & interaction
frontend/src/components/shared/Navbar.jsx
Replaces user display with getUserInitial chip, updates active/mobile link classes, reworks desktop Tools trigger (Enter/Space toggle, Escape close), and updates right-side auth/CTA layout.
Mobile menu & Tools accordion
frontend/src/components/shared/Navbar.jsx
Restyles hamburger row, implements chevron/tag-based Tools accordion with nested submenu expansion and standard item renderer, and reorganizes mobile auth/login/signup/user rows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #57: [UI/UX] Refactor Navbar for Improved Visual Hierarchy, Spacing Consistency, and Responsive Design — targets the same navbar visual/UX goals and responsive behavior.

Possibly related PRs

  • kunalverma2512/CodeLens#52: Modifies Navbar.jsx desktop/mobile "Tools" mega-menu behavior and markup with overlapping trigger/interaction changes and Escape handling.

Suggested labels

enhancement, Frontend, UI/UX, responsive, type:refactor, type:design, type:accessibility, level:intermediate, quality:clean

Poem

🐰 A small hop, a tidy tweak,
New badges, chevrons, menus sleek,
Handlers neat and layouts right,
Mobile hums, desktop takes flight,
A navbar polished — springtime bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of the PR: refactoring the navbar to improve visual hierarchy and responsive design, which directly aligns with the primary changes in the changeset.
Linked Issues check ✅ Passed The PR fully addresses the objectives in issue #57: improves visual hierarchy, spacing consistency, responsive design, reduces clutter, and implements keyboard accessibility enhancements for the mega menu.
Out of Scope Changes check ✅ Passed All changes are directly related to the navbar refactoring objectives in issue #57; no unrelated modifications to functionality, styling, or other components are present.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/shared/Navbar.jsx`:
- Around line 108-213: MegaMenuPanel lacks keyboard focus management: when
opened focus stays on the trigger and keyboard users can't reach the items.
Update MegaMenuPanel to accept a triggerRef prop (the trigger button ref), and
in a useEffect watch megaRef to detect when the panel becomes visible; when
visible, querySelector the first focusable element inside megaRef (e.g., first
Link from MEGA_MENU_ITEMS) and call .focus(); attach a keydown handler on the
panel that (a) closes and returns focus to triggerRef.current when Escape is
pressed by calling onClose(), (b) implements a simple focus-trap for
Tab/Shift+Tab by computing all tabbable elements inside megaRef and cycling
focus so Tab/Shift+Tab never escape the panel; ensure existing interactive
elements (Links) remain focusable and clean up event listeners on unmount/close.
- Around line 272-278: The mega menu leave timer (megaLeaveTimer) can fire after
unmount and call setMegaOpen on an unmounted component; add a cleanup to
clearTimeout(megaLeaveTimer.current) when the component unmounts (or when
relevant effect dependencies change). Locate the handlers handleMegaMouseEnter
and handleMegaMouseLeave and add a useEffect cleanup that checks
megaLeaveTimer.current and calls clearTimeout to prevent the pending timeout
from running after unmount.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66a8c1d6-5a97-4327-a234-c44fc74ad125

📥 Commits

Reviewing files that changed from the base of the PR and between 4879f17 and eec9c4e.

📒 Files selected for processing (1)
  • frontend/src/components/shared/Navbar.jsx

Comment on lines +108 to +213
function MegaMenuPanel({ megaRef, onMouseEnter, onMouseLeave, onClose }) {
return (
<div
id="tools-mega-menu"
role="region"
aria-label="Tools menu"
ref={megaRef}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className="absolute top-full left-1/2 mt-4 w-[620px] bg-white border border-zinc-200 shadow-2xl shadow-black/8 z-50 rounded-sm"
style={{ transform: "translateX(-50%)" }}
>
{/* Single thin top accent — replaces aggressive border-4 */}
<div className="h-0.5 w-full bg-black rounded-t-sm" />

<div className="p-5">
{/* Section label */}
<p className="text-[10px] font-semibold uppercase tracking-[0.18em] text-zinc-400 mb-4 pb-3 border-b border-zinc-100">
AI-Powered Tools — GSSoC '26
</p>

{/* Item grid — gap-px with bg-zinc-100 creates razor-thin dividers */}
<div className="grid grid-cols-2 gap-px bg-zinc-100 rounded-[2px] overflow-hidden">
{MEGA_MENU_ITEMS.map((item) => {
const hasSubmenu = item.submenu && item.submenu.length > 0;

// ── Contest Arsenal: full-width with nested submenu ────────────
if (hasSubmenu) {
return (
<div key={item.label} className="col-span-2">
{/* Parent header */}
<div className="bg-zinc-900 text-white px-4 py-3">
<div className="flex items-center gap-2">
<span className="text-sm leading-none opacity-70">{item.icon}</span>
<span className="text-xs font-bold uppercase tracking-[0.1em]">{item.label}</span>
<Tag label={item.tag} />
</div>
<p className="text-[11px] text-zinc-400 mt-1 pl-5 leading-snug font-normal">
{item.desc}
</p>
</div>
{/* Submenu grid */}
<div className="grid grid-cols-2 gap-px bg-zinc-100">
{item.submenu.map((sub) => (
<Link
key={sub.label}
to={sub.to}
onClick={onClose}
className="group bg-white px-4 py-3 hover:bg-zinc-900 hover:text-white transition-colors duration-150"
>
<div className="flex items-center gap-2 mb-0.5">
<span className="text-sm leading-none">{sub.icon}</span>
<span className="text-xs font-semibold uppercase tracking-[0.09em] group-hover:text-white">
{sub.label}
</span>
</div>
<p className="text-[11px] text-zinc-400 pl-5 leading-snug group-hover:text-zinc-300 font-normal">
{sub.desc}
</p>
</Link>
))}
</div>
</div>
);
}

// ── Standard grid item ─────────────────────────────────────────
const Wrapper = item.to ? Link : "div";
const wrapperProps = item.to ? { to: item.to, onClick: onClose } : {};

return (
<Wrapper
key={item.label}
{...wrapperProps}
className={`bg-white px-4 py-3 transition-colors duration-150 ${
item.to
? "cursor-pointer hover:bg-zinc-900 hover:text-white group"
: "cursor-default opacity-50"
}`}
>
<div className="flex items-center gap-2 mb-0.5">
<span className="text-sm leading-none opacity-70">{item.icon}</span>
<span className="text-xs font-semibold uppercase tracking-[0.09em]">{item.label}</span>
<Tag label={item.tag} />
</div>
<p className="text-[11px] text-zinc-400 pl-5 leading-snug group-hover:text-zinc-300 font-normal">
{item.desc}
</p>
</Wrapper>
);
})}
</div>

{/* Footer strip */}
<div className="mt-4 pt-3 border-t border-zinc-100 flex items-center justify-between">
<span className="text-[10px] font-medium uppercase tracking-[0.12em] text-zinc-400">
More tools shipping soon
</span>
<span className="text-[10px] font-semibold uppercase tracking-[0.1em] text-zinc-700 underline underline-offset-2 hover:text-black cursor-pointer transition-colors">
View All →
</span>
</div>
</div>
</div>
);
}
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 | 🟠 Major | 🏗️ Heavy lift

Add keyboard navigation support for mega menu items.

The MegaMenuPanel renders interactive Links but provides no keyboard navigation pattern. When a keyboard user opens the mega menu (via Enter/Space on the trigger), focus remains on the trigger button and users cannot Tab into the panel to navigate the items. This creates an accessibility gap for keyboard-only users who cannot reach the mega menu content.

Consider implementing focus management:

  • Move focus to the first menu item when the panel opens
  • Enable Tab/Shift+Tab navigation within the panel
  • Return focus to the trigger when the panel closes via Escape
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/shared/Navbar.jsx` around lines 108 - 213,
MegaMenuPanel lacks keyboard focus management: when opened focus stays on the
trigger and keyboard users can't reach the items. Update MegaMenuPanel to accept
a triggerRef prop (the trigger button ref), and in a useEffect watch megaRef to
detect when the panel becomes visible; when visible, querySelector the first
focusable element inside megaRef (e.g., first Link from MEGA_MENU_ITEMS) and
call .focus(); attach a keydown handler on the panel that (a) closes and returns
focus to triggerRef.current when Escape is pressed by calling onClose(), (b)
implements a simple focus-trap for Tab/Shift+Tab by computing all tabbable
elements inside megaRef and cycling focus so Tab/Shift+Tab never escape the
panel; ensure existing interactive elements (Links) remain focusable and clean
up event listeners on unmount/close.

Comment thread frontend/src/components/shared/Navbar.jsx
@Aish-kul16
Copy link
Copy Markdown
Contributor Author

Hi @kunalverma2512 , I’ve completed the navbar UI/UX refactor and opened this PR for review.

The refactor focuses on improving:

  • visual hierarchy
  • spacing consistency
  • responsive behavior
  • cleaner brutalist styling
  • overall navbar readability and structure

Looking forward to your feedback. Thanks!

@kunalverma2512
Copy link
Copy Markdown
Owner

@Aish-kul16 kindly look on coderabbitai and provide the reasoning whether its suggestion good or not
and if anything good for code then do it and finalize then
btw comparatively your navbar is looking good

also attach a video with good presentation about your work

@kunalverma2512
Copy link
Copy Markdown
Owner

@Aish-kul16 check technical discussion if not seen

@Aish-kul16
Copy link
Copy Markdown
Contributor Author

Hi @kunalverma2512 , Thanks for pointing this out. The suggestion is valid from an accessibility perspective since keyboard users currently cannot properly navigate into the mega menu after opening it.

I agree that basic focus management should be improved here. I’m planning to implement lightweight keyboard accessibility support (focus transfer + escape handling) without overcomplicating the current navbar architecture or UX scope.

@kunalverma2512
Copy link
Copy Markdown
Owner

@Aish-kul16 go ahead

@kunalverma2512
Copy link
Copy Markdown
Owner

@Aish-kul16 coderabbitai suggestions are valid and worth implementing.

CodeRabbit sometimes gives optional improvements too, but in this PR both points are meaningful from accessibility and React lifecycle perspectives.

Go ahead with:

  • proper keyboard navigation/focus flow
  • Escape focus restoration
  • timer cleanup on unmount

Keep the implementation clean and lightweight without overengineering the navbar architecture.

Once finalized, attach the demo video properly and make sure to explain things whatever you done and then we can move ahead.

@Aish-kul16
Copy link
Copy Markdown
Contributor Author

Hi @kunalverma2512 , I’ve implemented the CodeRabbit suggestions and pushed the accessibility + cleanup fixes to the PR.

  1. The mega menu now supports improved keyboard accessibility, focus restoration, and timer cleanup handling.

  2. I’m currently preparing a proper demo video presentation and will attach it shortly

kindly review it, thank you .

@kunalverma2512
Copy link
Copy Markdown
Owner

@coderabbitai please perform a full review of this PR and verify whether the implementation, code quality, accessibility, responsiveness, and overall architecture are properly handled.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me read the full Navbar.jsx file to perform a thorough review.


🏁 Script executed:

#!/bin/bash
cat frontend/src/components/shared/Navbar.jsx

Length of output: 27950


PR description images:

  • Image 1 (Before): Navbar shows "CODELENS" wordmark, center nav with DASHBOARD (underlined), EXPLORE, CODEFORCES, ACCOUNT CENTER, TOOLS ▾, then right side: APEX (solid black), a separator, "K KUNALVER..." dropdown, GITHUB DATA button, LOGOUT button — feels busy and cluttered.
  • Image 2 (After): Cleaner header with the same wordmark, DASHBOARD, EXPLORE, CODEFORCES, ACCOUNT, TOOLS ▾ in lighter center, then APEX (solid black), "A AISH" identity chip, GITHUB, LOGOUT — visually lighter, better hierarchy. The hero section beneath shows the full landing experience.

@kunalverma2512 — Full review below. The refactor is a solid improvement overall, but there are a few issues — one of them directly undermines the keyboard accessibility work that was already done.


✅ What's Working Well

Area Status
Timer cleanup on unmount (clearTimeout) ✅ Done
Escape key on trigger button (close + refocus) ✅ Done
Escape key bubbling from panel children ✅ Done
Outside-click close via mousedown ✅ Done
Mobile menu close on route change ✅ Done
Scroll shadow with passive listener + cleanup ✅ Done
aria-haspopup, aria-expanded, aria-controls on trigger ✅ Done
focus-visible rings on all interactive elements ✅ Done
role="region" + aria-label on panel ✅ Done
Mobile hamburger aria-label / aria-expanded ✅ Done
Visual hierarchy & spacing improvements ✅ Clear win

🔴 Issues Found

1. Focus Is Hijacked on Mouse Hover (High — Accessibility Bug)

In handleMegaMouseEnter, focus is transferred to the first menu item unconditionally:

const handleMegaMouseEnter = () => {
  clearTimeout(megaLeaveTimer.current);
  setMegaOpen(true);
  setTimeout(() => {
    firstMenuItemRef.current?.focus(); // ← fires on every mouse hover
  }, 0);
};

This means when a mouse user simply moves their cursor over "Tools", the browser's focus jumps into the mega menu. This is disruptive — it can trigger scroll jumps, break screen reader announcements, and violate WCAG 2.1 guideline 3.2.1 (On Focus). Focus should only be moved programmatically on keyboard activation.

Fix: Move focus transfer exclusively into the keyboard handler on the trigger button, where it already exists:

const handleMegaMouseEnter = () => {
  clearTimeout(megaLeaveTimer.current);
  setMegaOpen(true);
  // ← do NOT call focus() here
};

The trigger's onKeyDown already handles focus for keyboard users:

if (e.key === "Enter" || e.key === " ") {
  e.preventDefault();
  setMegaOpen((v) => !v);
  setTimeout(() => {
    firstMenuItemRef.current?.focus(); // ← only on keyboard, correct
  }, 0);
}

2. Mega Menu Stays Open When User Tabs Past It (Medium — Accessibility)

There is no handler to close the menu when keyboard focus leaves the panel entirely. A user who opens the menu with the keyboard and then Tabs through all the links will land on whatever comes after the mega menu in the tab order, with the mega menu still visually open.

Fix: Add a onBlur handler using relatedTarget to detect focus leaving the panel bounds:

// In MegaMenuPanel
onBlur={(e) => {
  if (
    !e.currentTarget.contains(e.relatedTarget) &&
    !megaTriggerRef.current?.contains(e.relatedTarget)
  ) {
    onClose();
  }
}}

3. "View All →" Is Not Keyboard Accessible (Medium — Accessibility)

In the mega menu footer:

<span
  className="... cursor-pointer ... hover:text-black"
>
  View All →
</span>

This element has hover styles and cursor-pointer implying interactivity, but has no tabIndex, no role, and no onClick handler. It is invisible to keyboard and screen reader users.

Fix: Either make it a proper <Link> or <button>, or if it leads nowhere yet, remove the pointer styles:

// Option A: make it navigable
<Link to="/tools" onClick={onClose} className="...">View All →</Link>

// Option B: mark it as coming soon / non-interactive
<span className="text-[10px] font-medium ... text-zinc-400 cursor-default">
  View All  Coming Soon
</span>

4. Mobile Tools Accordion Missing aria-controls (Medium — Accessibility)

The desktop trigger correctly has aria-controls="tools-mega-menu" linking it to the panel, but the mobile accordion button does not:

<button
  aria-expanded={mobileMegaOpen}
  aria-haspopup="true"
  // ← missing aria-controls
  onClick={() => setMobileMegaOpen((v) => !v)}
  ...
>

Fix:

<button
  aria-expanded={mobileMegaOpen}
  aria-haspopup="true"
  aria-controls="mobile-tools-panel"
  ...
>

<div id="mobile-tools-panel" ...>
  {/* mobile menu items */}
</div>

5. shadow-black/8 Is a Non-Standard Tailwind Opacity (Medium — Rendering)

className="... shadow-2xl shadow-black/8 ..."

Tailwind's built-in opacity scale uses multiples of 5 (5, 10, 15…). /8 is not in the default palette and will likely be silently ignored (no shadow rendered) unless arbitrary values are enabled via tailwind.config.js. Use /10 or the arbitrary syntax:

shadow-black/10
// or
shadow-[rgba(0,0,0,0.08)]

6. Cleanup useEffect Has Inconsistent Indentation (Low — Code Quality)

  useEffect(() => {
  return () => {              // ← should be indented 2 more spaces
    clearTimeout(megaLeaveTimer.current);
  };
}, []);                       // ← closing brace at column-0

Should be:

  useEffect(() => {
    return () => {
      clearTimeout(megaLeaveTimer.current);
    };
  }, []);

Summary

# Issue Severity Category
1 Focus jumps on mouse hover in handleMegaMouseEnter 🔴 High Accessibility
2 Mega menu doesn't close on Tab-out 🟠 Medium Accessibility
3 "View All →" not keyboard/screen-reader accessible 🟠 Medium Accessibility
4 Mobile accordion missing aria-controls 🟠 Medium Accessibility
5 shadow-black/8 non-standard Tailwind value 🟠 Medium Rendering
6 Cleanup useEffect indentation 🟡 Low Code Quality

Issues 1–3 are direct accessibility concerns worth fixing before merge. Issue 1 in particular partially negates the keyboard accessibility work already done. Issues 4–6 are straightforward cleanup items.

The visual redesign itself — the spacing, typography scale, hierarchy, and brutalist language — is a genuine improvement over the original. Once these items are addressed and the demo video is attached, this should be good to go.

@Aish-kul16
Copy link
Copy Markdown
Contributor Author

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain
Let me read the full Navbar.jsx file to perform a thorough review.

🏁 Script executed:

#!/bin/bash
cat frontend/src/components/shared/Navbar.jsx

Length of output: 27950

PR description images:

  • Image 1 (Before): Navbar shows "CODELENS" wordmark, center nav with DASHBOARD (underlined), EXPLORE, CODEFORCES, ACCOUNT CENTER, TOOLS ▾, then right side: APEX (solid black), a separator, "K KUNALVER..." dropdown, GITHUB DATA button, LOGOUT button — feels busy and cluttered.
  • Image 2 (After): Cleaner header with the same wordmark, DASHBOARD, EXPLORE, CODEFORCES, ACCOUNT, TOOLS ▾ in lighter center, then APEX (solid black), "A AISH" identity chip, GITHUB, LOGOUT — visually lighter, better hierarchy. The hero section beneath shows the full landing experience.

@kunalverma2512 — Full review below. The refactor is a solid improvement overall, but there are a few issues — one of them directly undermines the keyboard accessibility work that was already done.

✅ What's Working Well

Area Status
Timer cleanup on unmount (clearTimeout) ✅ Done
Escape key on trigger button (close + refocus) ✅ Done
Escape key bubbling from panel children ✅ Done
Outside-click close via mousedown ✅ Done
Mobile menu close on route change ✅ Done
Scroll shadow with passive listener + cleanup ✅ Done
aria-haspopup, aria-expanded, aria-controls on trigger ✅ Done
focus-visible rings on all interactive elements ✅ Done
role="region" + aria-label on panel ✅ Done
Mobile hamburger aria-label / aria-expanded ✅ Done
Visual hierarchy & spacing improvements ✅ Clear win

🔴 Issues Found

1. Focus Is Hijacked on Mouse Hover (High — Accessibility Bug)

In handleMegaMouseEnter, focus is transferred to the first menu item unconditionally:

const handleMegaMouseEnter = () => {
  clearTimeout(megaLeaveTimer.current);
  setMegaOpen(true);
  setTimeout(() => {
    firstMenuItemRef.current?.focus(); // ← fires on every mouse hover
  }, 0);
};

This means when a mouse user simply moves their cursor over "Tools", the browser's focus jumps into the mega menu. This is disruptive — it can trigger scroll jumps, break screen reader announcements, and violate WCAG 2.1 guideline 3.2.1 (On Focus). Focus should only be moved programmatically on keyboard activation.

Fix: Move focus transfer exclusively into the keyboard handler on the trigger button, where it already exists:

const handleMegaMouseEnter = () => {
  clearTimeout(megaLeaveTimer.current);
  setMegaOpen(true);
  // ← do NOT call focus() here
};

The trigger's onKeyDown already handles focus for keyboard users:

if (e.key === "Enter" || e.key === " ") {
  e.preventDefault();
  setMegaOpen((v) => !v);
  setTimeout(() => {
    firstMenuItemRef.current?.focus(); // ← only on keyboard, correct
  }, 0);
}

2. Mega Menu Stays Open When User Tabs Past It (Medium — Accessibility)

There is no handler to close the menu when keyboard focus leaves the panel entirely. A user who opens the menu with the keyboard and then Tabs through all the links will land on whatever comes after the mega menu in the tab order, with the mega menu still visually open.

Fix: Add a onBlur handler using relatedTarget to detect focus leaving the panel bounds:

// In MegaMenuPanel
onBlur={(e) => {
  if (
    !e.currentTarget.contains(e.relatedTarget) &&
    !megaTriggerRef.current?.contains(e.relatedTarget)
  ) {
    onClose();
  }
}}

3. "View All →" Is Not Keyboard Accessible (Medium — Accessibility)

In the mega menu footer:

<span
  className="... cursor-pointer ... hover:text-black"
>
  View All →
</span>

This element has hover styles and cursor-pointer implying interactivity, but has no tabIndex, no role, and no onClick handler. It is invisible to keyboard and screen reader users.

Fix: Either make it a proper <Link> or <button>, or if it leads nowhere yet, remove the pointer styles:

// Option A: make it navigable
<Link to="/tools" onClick={onClose} className="...">View All →</Link>

// Option B: mark it as coming soon / non-interactive
<span className="text-[10px] font-medium ... text-zinc-400 cursor-default">
  View All  Coming Soon
</span>

4. Mobile Tools Accordion Missing aria-controls (Medium — Accessibility)

The desktop trigger correctly has aria-controls="tools-mega-menu" linking it to the panel, but the mobile accordion button does not:

<button
  aria-expanded={mobileMegaOpen}
  aria-haspopup="true"
  // ← missing aria-controls
  onClick={() => setMobileMegaOpen((v) => !v)}
  ...
>

Fix:

<button
  aria-expanded={mobileMegaOpen}
  aria-haspopup="true"
  aria-controls="mobile-tools-panel"
  ...
>

<div id="mobile-tools-panel" ...>
  {/* mobile menu items */}
</div>

5. shadow-black/8 Is a Non-Standard Tailwind Opacity (Medium — Rendering)

className="... shadow-2xl shadow-black/8 ..."

Tailwind's built-in opacity scale uses multiples of 5 (5, 10, 15…). /8 is not in the default palette and will likely be silently ignored (no shadow rendered) unless arbitrary values are enabled via tailwind.config.js. Use /10 or the arbitrary syntax:

shadow-black/10
// or
shadow-[rgba(0,0,0,0.08)]

6. Cleanup useEffect Has Inconsistent Indentation (Low — Code Quality)

  useEffect(() => {
  return () => {              // ← should be indented 2 more spaces
    clearTimeout(megaLeaveTimer.current);
  };
}, []);                       // ← closing brace at column-0

Should be:

  useEffect(() => {
    return () => {
      clearTimeout(megaLeaveTimer.current);
    };
  }, []);

Summary

Issue Severity Category

1 Focus jumps on mouse hover in handleMegaMouseEnter 🔴 High Accessibility
2 Mega menu doesn't close on Tab-out 🟠 Medium Accessibility
3 "View All →" not keyboard/screen-reader accessible 🟠 Medium Accessibility
4 Mobile accordion missing aria-controls 🟠 Medium Accessibility
5 shadow-black/8 non-standard Tailwind value 🟠 Medium Rendering
6 Cleanup useEffect indentation 🟡 Low Code Quality
Issues 1–3 are direct accessibility concerns worth fixing before merge. Issue 1 in particular partially negates the keyboard accessibility work already done. Issues 4–6 are straightforward cleanup items.

The visual redesign itself — the spacing, typography scale, hierarchy, and brutalist language — is a genuine improvement over the original. Once these items are addressed and the demo video is attached, this should be good to go.

Thank you so much for the review and guidance throughout the PR process @kunalverma2512.

I also went through this remaining CodeRabbit suggestions carefully. Do you want me to work on those accessibility improvements as well in a separate follow-up PR? Do let me know .

@kunalverma2512
Copy link
Copy Markdown
Owner

@Aish-kul16 thanks
I would say to make that issue and work after sometime but work on some different issue right now

@kunalverma2512 kunalverma2512 merged commit d2f35e0 into kunalverma2512:main May 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI/UX] Refactor Navbar for Improved Visual Hierarchy, Spacing Consistency, and Responsive Design

2 participants