Skip to content

OCD-5292 | Navigation and Active State Handling#1518

Open
mattystank wants to merge 7 commits into
chpladmin:stagingfrom
mattystank:OCD-5292
Open

OCD-5292 | Navigation and Active State Handling#1518
mattystank wants to merge 7 commits into
chpladmin:stagingfrom
mattystank:OCD-5292

Conversation

@mattystank

Copy link
Copy Markdown
Contributor

This pull request enhances the navigation components across the application by improving active state highlighting, refining menu item styling, and unifying navigation behavior for both desktop and mobile views. The changes ensure a more consistent user experience by visually indicating the current page, handling navigation events more robustly, and improving accessibility and analytics tracking.

Navigation and Active State Handling:

  • Added logic to track the current URL hash and highlight the active menu item in admin-menu-link-item.jsx, desktop-nav.jsx, and mobile-nav-drawer.jsx for better user feedback. [1] [2] [3] [4] [5] [6]

Styling and Visual Improvements:

  • Updated styles for menu items and dropdowns to include hover effects, bold/black text for active items, and removed underlines from links for a cleaner look. [1] [2] [3]

Navigation Behavior and Analytics:

  • Unified the menu item click handlers to properly handle navigation (including Angular state transitions), close menus, and trigger analytics events where appropriate in both desktop and mobile navigation. [1] [2] [3] [4]

Code Quality and Imports:

  • Added necessary imports for Angular service helpers and analytics tracking in all affected files. [1] [2] [3] [4]

Component Clean-up:

  • Removed the now-unnecessary indicateOnHover prop from ChplLink usage in navigation components. [1] [2]

These changes collectively improve navigation clarity, maintainability, and user experience throughout the app.

@mattystank mattystank changed the title OCD-5292 OCD-5292 | Navigation and Active State Handling Jun 24, 2026
Comment thread src/app/components/login/navigation/admin-menu-link-item.jsx Outdated
Comment thread src/app/components/login/navigation/admin-menu-link-item.jsx
@mattystank mattystank marked this pull request as ready for review June 25, 2026 12:59
Comment thread src/app/navigation/desktop-nav.jsx Outdated
Comment thread src/app/navigation/desktop-nav.jsx Outdated
Comment thread src/app/navigation/mobile-nav-drawer.jsx Outdated
andlar
andlar previously approved these changes Jul 2, 2026
color: palette.primary,
fontSize: '14px',
'&:hover': {
backgroundColor: `${palette.secondary} !important`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this !important actually important?

return () => window.removeEventListener('hashchange', handleHashChange);
}, []);

const isActive = href && currentHash === href;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the point of this? It's not a function, which I'd expect it to be if it's dependent on some state variable or variables. href must be defined, as per the propTypes definition, and this const? is only used in one place. It's just confusing. Couldn't the place where it's used just have the currentHash === href line inside the ${isActive... part?

drawerItem: {
color: palette.greyDark,
'&:hover': {
backgroundColor: `${palette.secondary} !important`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is !important required? I'm having trouble checking on this. If it's truly important, that's fine, but that tag is such a strong indicator that it can easily override something else, so should be used only when absolutely required

Comment on lines +127 to +132
useEffect(() => {
const handleHashChange = () => setCurrentHash(window.location.hash);
window.addEventListener('hashchange', handleHashChange);
return () => window.removeEventListener('hashchange', handleHashChange);
}, []);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've seen this construct three times in three files. If it was just once, that would be fine. If it was twice, that would suggest an option to raise it. Once it hits three times it should be in some sort of upper context level

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.

2 participants