Skip to content

Fix navbar underline alignment issue on Tools hover (Approach 2)#52

Merged
kunalverma2512 merged 5 commits into
kunalverma2512:mainfrom
Ushnika09:fix/navbar-underline-approach-2
May 16, 2026
Merged

Fix navbar underline alignment issue on Tools hover (Approach 2)#52
kunalverma2512 merged 5 commits into
kunalverma2512:mainfrom
Ushnika09:fix/navbar-underline-approach-2

Conversation

@Ushnika09
Copy link
Copy Markdown
Contributor

@Ushnika09 Ushnika09 commented May 15, 2026

Overview(Fixes #28 )

This PR implements Approach 2 for fixing the navbar underline alignment issue on the Tools menu item

Instead of applying the underline styling to the entire button container, this approach isolates the underline effect specifically to the Tools text element. This prevents the dropdown icon from affecting underline positioning and alignment.

Changes Made

  • Moved underline styling from the parent button element to the Tools text span
  • Kept the rotating dropdown icon interaction
  • Prevented underline interference from the dropdown arrow
  • Maintained existing navbar responsiveness and brutalist UI styling
  • Improved hover/open state alignment consistency

Result

  • Underline remains properly aligned beneath the Tools text
  • Dropdown icon no longer affects underline positioning
  • Smoother and more visually consistent navbar interaction

Preview

https://www.loom.com/share/100700afc36a44a282d05be2d922e1dc

Summary by CodeRabbit

  • Style

    • Moved visual underline/decoration into an inner element for consistent desktop appearance and adjusted mobile submenu chevron behavior.
  • Accessibility

    • Added ARIA attributes and keyboard handlers to desktop and mobile menu controls; labeled mega-menu as a dialog and improved mobile hamburger focus styling.
  • Refactor

    • Wrapped icons and labels in dedicated spans to stabilize markup and styling.

Review Change Stack

@github-actions
Copy link
Copy Markdown

🚀 PR Received Successfully

Hello @Ushnika09,

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 15, 2026

📝 Walkthrough

Walkthrough

Refactors the Navbar "Tools" mega-menu: desktop trigger styling moved into an inner span, keyboard handlers and ARIA attributes added, mega-menu panel receives dialog semantics, icon/label markup is split into dedicated spans, and mobile hamburger/accordion accessibility and focus styling updated.

Changes

Navbar mega-menu accessibility and markup

Layer / File(s) Summary
Desktop trigger, panel, and item markup
frontend/src/components/shared/Navbar.jsx
Desktop "Tools" trigger moves underline/decoration into an inner <span>, adds aria-controls/aria-expanded and Enter/Space/Escape keyboard handling; mega-menu panel gets id="tools-mega-menu", role="dialog", aria-label; mega-menu item and submenu icons are wrapped in dedicated <span> elements.
Mobile hamburger, accordion, and submenu markup
frontend/src/components/shared/Navbar.jsx
Mobile hamburger gains focus-visible ring styling; "Tools" accordion adds aria-expanded/aria-haspopup; submenu toggle buttons gain aria-expanded and updated click handling; submenu and list item markup split icon and label into separate spans and chevron rotation styles reorganized.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐰 I hopped into the Navbar light,
Moved the line where it could bite,
Keys now open, Escape says no,
Icons and labels in tidy rows,
A neat little hop — tidy site.

🚥 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 accurately reflects the main change: fixing a navbar underline alignment issue on the Tools hover state by moving underline styling from the button to an inner span (Approach 2).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

🧹 Nitpick comments (1)
frontend/src/components/shared/Navbar.jsx (1)

191-191: ⚡ Quick win

Remove unused decoration classes from button.

The decoration-4 and decoration-black classes on the button have no effect because the button doesn't have an underline class. These decoration classes are now properly applied to the inner span (line 196) where the conditional underline lives. Removing them from the button improves clarity and eliminates dead code.

♻️ Proposed cleanup
-              className={`text-sm font-black uppercase tracking-widest text-black flex items-center gap-1 transition-all duration-150 decoration-4 decoration-black focus:outline-none `}
+              className={`text-sm font-black uppercase tracking-widest text-black flex items-center gap-1 transition-all duration-150 focus:outline-none`}
🤖 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` at line 191, Remove the dead
decoration classes from the button's className in Navbar.jsx: locate the button
element using the className string containing "text-sm font-black uppercase
tracking-widest text-black flex items-center gap-1 transition-all duration-150"
and remove "decoration-4" and "decoration-black" since the underline/decoration
is already applied on the inner span (the conditional underline at the inner
span around line 196); keep the rest of the classes intact to preserve styling
and focus behavior.
🤖 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.

Nitpick comments:
In `@frontend/src/components/shared/Navbar.jsx`:
- Line 191: Remove the dead decoration classes from the button's className in
Navbar.jsx: locate the button element using the className string containing
"text-sm font-black uppercase tracking-widest text-black flex items-center gap-1
transition-all duration-150" and remove "decoration-4" and "decoration-black"
since the underline/decoration is already applied on the inner span (the
conditional underline at the inner span around line 196); keep the rest of the
classes intact to preserve styling and focus behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 12bee39b-96ad-4693-ba05-a19eb5380f38

📥 Commits

Reviewing files that changed from the base of the PR and between 12e4428 and d01e3d2.

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

@kunalverma2512
Copy link
Copy Markdown
Owner

@Ushnika09 coderabbitai has indicated some changes
see it and then come up again..

@Ushnika09
Copy link
Copy Markdown
Contributor Author

Addressed the review suggestion by removing the unused underline decoration classes from the parent button since the underline styling is now handled by the inner Tools text span. This keeps the implementation cleaner and avoids redundant styling

@kunalverma2512
Copy link
Copy Markdown
Owner

@coderabbitai review

@kunalverma2512
Copy link
Copy Markdown
Owner

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

✅ Actions performed

Full review triggered.

Repository owner deleted a comment from coderabbitai Bot May 15, 2026
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: 1

🤖 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`:
- Line 191: The Tools button's className currently includes
"focus:outline-none", which removes the focus indicator and breaks keyboard
accessibility; update the className in the Navbar component (the JSX element
that contains className={`text-sm font-black uppercase tracking-widest
text-black flex items-center gap-1 transition-all duration-150
focus:outline-none `}) by removing "focus:outline-none" or replacing it with an
accessible focus style such as "focus:ring-4 focus:ring-black" (or similar
Tailwind focus utilities) so keyboard users regain a visible focus ring.
🪄 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: 0987c0c7-3c83-473a-a8f4-2f7e140235a0

📥 Commits

Reviewing files that changed from the base of the PR and between 12e4428 and d666447.

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

Comment thread frontend/src/components/shared/Navbar.jsx Outdated
@kunalverma2512
Copy link
Copy Markdown
Owner

@Ushnika09 recheck again coderabbitai comment and make sure to see again its comments in future commits if it does provide more amendments to do

@Ushnika09
Copy link
Copy Markdown
Contributor Author

@coderabbitai If I replace focus:outline-none with a custom focus ring, will that resolve the accessibility concern completely or do you see any additional issues?

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
fd "Navbar.jsx" --exec cat {}

Length of output: 24332


@Ushnika09 Great question! Replacing focus:outline-none with a custom focus ring is a necessary fix, but not sufficient on its own. Here's a complete picture of what to address:


✅ Fix 1 — Custom focus ring (your proposed change)

Replace focus:outline-none on both the desktop Tools button and the mobile hamburger with a visible focus ring. Using focus-visible is preferred as it only shows for keyboard users:

// Desktop Tools button
className={`... focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2`}

// Mobile hamburger button
className="... focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2"

⚠️ Fix 2 — Keyboard operability (bigger gap)

The mega menu only opens on hover — keyboard users cannot open or close it at all. You need a onKeyDown handler on the desktop Tools button:

<button
  ref={megaTriggerRef}
  onKeyDown={(e) => {
    if (e.key === "Enter" || e.key === " ") {
      e.preventDefault();
      setMegaOpen((v) => !v);
    }
    if (e.key === "Escape") {
      setMegaOpen(false);
    }
  }}
  aria-haspopup="true"
  aria-expanded={megaOpen}
  aria-controls="tools-mega-menu"  // ← add this
  ...
>

⚠️ Fix 3 — Link the panel with aria-controls

Add an id to the mega menu panel to match aria-controls on the trigger:

<div
  id="tools-mega-menu"
  ref={megaRef}
  role="dialog"
  aria-label="Tools menu"
  ...
>

⚠️ Fix 4 — Mobile accordion button missing aria-expanded

The mobile Tools accordion button (~line 331) is missing aria-expanded:

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

⚠️ Fix 5 — Mobile submenu expand button missing aria-expanded

The "Contest Arsenal" expand button inside the mobile menu is also missing aria-expanded:

<button
  onClick={() => setExpandedSubmenu(isExpanded ? null : item.label)}
  aria-expanded={isExpanded}   // ← missing
  ...
>

Summary

Concern Status after your proposed fix
Focus ring visibility (desktop Tools btn + hamburger) ✅ Resolved
Keyboard open/close for mega menu ❌ Still missing
aria-controls linkage ❌ Still missing
Mobile accordion aria-expanded ❌ Still missing
Mobile submenu aria-expanded ❌ Still missing

Fixes 2–5 are independent of the focus ring — addressing all of them together will make the navbar fully accessible for keyboard and screen reader users. Let me know if you'd like help implementing any of these!

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: 1

🧹 Nitpick comments (2)
frontend/src/components/shared/Navbar.jsx (2)

491-495: ⚡ Quick win

Add aria-haspopup="true" to submenu toggle button for consistency.

The submenu toggle button has aria-expanded but is missing aria-haspopup, which describes that the button reveals a popup submenu. Adding this attribute maintains consistency with the desktop Tools trigger (line 191) and mobile Tools accordion (line 464) disclosure patterns.

♿ Proposed fix for ARIA attributes
                         <button
                           aria-expanded={isExpanded}
+                          aria-haspopup="true"
                           onClick={() =>
🤖 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 491 - 495, The
submenu toggle button lacks aria-haspopup; update the button element that uses
aria-expanded={isExpanded} and onClick={() => setExpandedSubmenu(isExpanded ?
null : item.label)} to also include aria-haspopup="true" so it consistently
indicates a popup submenu (match the desktop Tools trigger and mobile Tools
accordion patterns); locate the button that references isExpanded,
setExpandedSubmenu and item.label and add the aria attribute.

259-261: ⚡ Quick win

Add aria-hidden="true" to decorative icon spans.

The icon characters (emoji/symbols like ⌥, ◬, ⚔) are supplementary to the text labels, which already convey full meaning. Screen readers may announce these symbols in confusing ways. Adding aria-hidden="true" improves the screen reader experience by preventing redundant or unclear announcements.

This pattern applies to all icon spans throughout the mega menu (lines 259-261, 286-288, 313-315, 500-502, 536-538, and others).

♿ Proposed fix for icon accessibility
-                                <span className="text-base font-black leading-none">
+                                <span className="text-base font-black leading-none" aria-hidden="true">
                                   {item.icon}
                                 </span>
🤖 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 259 - 261, The
decorative icon spans (e.g., the JSX span rendering {item.icon} with className
"text-base font-black leading-none" in Navbar.jsx and other similar icon spans
in the mega menu) should include aria-hidden="true" so screen readers ignore
redundant symbols; locate each span that only renders an icon/emoji (not
meaningful text or interactive controls) and add the aria-hidden="true"
attribute to those span elements (repeat for other icon spans with similar
classNames where icons are decorative).
🤖 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`:
- Line 228: In Navbar.jsx update the navigation mega-menu element that currently
sets role="dialog" (inside the Navbar component) to use role="region" instead
and add a descriptive aria-label (e.g., aria-label="Main navigation" or specific
section name) so assistive tech recognizes it as a landmark; alternatively
remove the explicit role if you prefer relying on native semantics—locate the
element with role="dialog" in the Navbar component and replace the role and add
aria-label accordingly.

---

Nitpick comments:
In `@frontend/src/components/shared/Navbar.jsx`:
- Around line 491-495: The submenu toggle button lacks aria-haspopup; update the
button element that uses aria-expanded={isExpanded} and onClick={() =>
setExpandedSubmenu(isExpanded ? null : item.label)} to also include
aria-haspopup="true" so it consistently indicates a popup submenu (match the
desktop Tools trigger and mobile Tools accordion patterns); locate the button
that references isExpanded, setExpandedSubmenu and item.label and add the aria
attribute.
- Around line 259-261: The decorative icon spans (e.g., the JSX span rendering
{item.icon} with className "text-base font-black leading-none" in Navbar.jsx and
other similar icon spans in the mega menu) should include aria-hidden="true" so
screen readers ignore redundant symbols; locate each span that only renders an
icon/emoji (not meaningful text or interactive controls) and add the
aria-hidden="true" attribute to those span elements (repeat for other icon spans
with similar classNames where icons are decorative).
🪄 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: 613d234a-6591-4114-9956-289bab9c9d7e

📥 Commits

Reviewing files that changed from the base of the PR and between d666447 and bdd40e6.

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

Comment thread frontend/src/components/shared/Navbar.jsx Outdated
@kunalverma2512
Copy link
Copy Markdown
Owner

@Ushnika09 have you gone with the reasoning of coderabbitai ?

@Ushnika09
Copy link
Copy Markdown
Contributor Author

@kunalverma2512 yes, I thought it would be better to refine the related accessibility concerns together at instead of iterating on the same idea multiple times in separate commits.

@kunalverma2512
Copy link
Copy Markdown
Owner

@Ushnika09 go ahead and come up

@Ushnika09
Copy link
Copy Markdown
Contributor Author

@coderabbitai review the latest changes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
fd "Navbar.jsx" --exec cat {}

Length of output: 27199


@Ushnika09 Great work addressing all the accessibility concerns from the previous review! Here's the full status:

✅ All Previously Flagged Issues Resolved

Concern Status
Focus ring visibility (desktop Tools btn + hamburger) ✅ Fixed with focus-visible:ring-*
Keyboard open/close for mega menu (Enter/Space/Escape) ✅ Fixed
aria-controls / aria-expanded / aria-haspopup on desktop trigger ✅ Fixed
Mega menu panel id, role, aria-label ✅ Fixed
Mobile accordion aria-expanded + aria-haspopup ✅ Fixed
Mobile submenu (Contest Arsenal) aria-expanded ✅ Fixed

Note: role="region" on the mega menu panel is actually the right semantic choice over role="dialog" (since it's not a modal), so that's a good call.


🔍 One Minor Remaining Inconsistency

All other nav links show an underline on hover (via hover:underline), but the Tools button inner span only applies the underline when megaOpen is true. Consider adding hover underline to match:

<span
  className={`${
    megaOpen
      ? "underline underline-offset-8 decoration-4 decoration-black"
      : "hover:underline hover:underline-offset-8 hover:decoration-4 hover:decoration-black"
  }`}
>
  Tools
</span>

This is a small polish item for consistency with the rest of the navbar. Everything else looks solid — the PR is in great shape! 🎉

@Ushnika09
Copy link
Copy Markdown
Contributor Author

@coderabbitai In the current implementation, hovering the Tools button already triggers handleMegaMouseEnter, which sets megaOpen to true and applies the underline state. Since the underline is already appearing on hover through the open state, I don’t think adding hover:underline separately is necessary here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Tip

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

@Ushnika09 That's a fair and well-reasoned point! Since handleMegaMouseEnter fires on hover and sets megaOpen to true, the underline is effectively applied on hover through the state-driven path — so adding a redundant hover:underline class isn't necessary. The behavior is equivalent in practice. Thanks for walking through the reasoning — the implementation looks good! 🎉

(ノ◕ヮ◕)ノ*:・゚✧

@kunalverma2512
Copy link
Copy Markdown
Owner

kunalverma2512 commented May 16, 2026

@Ushnika09 update as soon as you finalize and make sure to again showcase by loom preview

@Ushnika09
Copy link
Copy Markdown
Contributor Author

@kunalverma2512, Already aligned the changes with the review guidance. Here’s the updated Loom preview showcasing the latest implementation:

https://www.loom.com/share/11f6acf4bcfc485182741883d89c25ec

@kunalverma2512
Copy link
Copy Markdown
Owner

@Ushnika09

Good.
Changes are now looking properly aligned with the review guidance and the updated Loom showcase was expected.
update that this work in done in corresponding issue
Maintain this level of iteration quality, communication, and responsiveness in future contributions as well. 👍

@kunalverma2512 kunalverma2512 merged commit b3c6aaf into kunalverma2512:main May 16, 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.

Navbar Underline Position Breaks on Tools Hover

2 participants