Skip to content

feat(nav): Open secondary navigation in overlay when collapsed #92055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 22, 2025

Conversation

malwilley
Copy link
Member

@malwilley malwilley commented May 21, 2025

Before, when the navigation was collapsed, we would pop open the sidebar when hovering anywhere in the primary nav. New behavior will display each individual section in an overlay.

CleanShot.2025-05-21.at.12.42.32.mp4

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 21, 2025
/**
* Whether to animate the hovercard in/out
*/
animated?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this config option to allow the animation to be disabled

update: (() => Promise<Partial<State>>) | null;
}

const HovercardContext = createContext<HovercardProviderValue>({
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a context here so that children can call reset to close the overlay when needed. This allows me to dismiss the overlay when a link is clicked.

@@ -26,7 +28,7 @@ function CodecovSecondaryNav() {
});

return (
<SecondaryNav>
<Fragment>
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this SecondaryNav wrapper from the *SecondaryNav components to a single parent component since we do not want it in the overlay.

@malwilley malwilley marked this pull request as ready for review May 21, 2025 20:19
@malwilley malwilley requested a review from a team as a code owner May 21, 2025 20:19
Copy link
Member

@MichaelSun48 MichaelSun48 left a comment

Choose a reason for hiding this comment

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

code looks good to me! minor nit: the overscroll behavior is a little wonky here

Screen.Recording.2025-05-21.at.1.35.34.PM.mov

also not sure if this is a problem, but the vercel preview doesn't work for me (i get the "It looks like you've hit an issue in our client application" message), but it works fine in local dev-ui

nvm working now

@TkDodo
Copy link
Contributor

TkDodo commented May 22, 2025

I tried this out locally and wanted to note that it’s not possible to get into the secondary sidebar when doing keyboard navigation:

secondary-sidebar-keyboard.mp4

Also, when trying to get into it with the mouse, I managed to get it to close before moving the mouse into it a bunch of times, which was a bit frustrating:

secondary-navigation-mouse.mp4

@malwilley
Copy link
Member Author

I tried this out locally and wanted to note that it’s not possible to get into the secondary sidebar when doing keyboard navigation:

@TkDodo thank you for pointing this out! I agree that ideally this would be keyboard navigable. I just spent some time trying to figure out how to make it so, but I'm not so sure I've found anything that feels right.

There are a couple options:

  1. Add the sub-menu items to the tab order. I was able to make this work, but it makes tabbing to to other nav sections (or the main content) quite difficult
  2. A more complex arrow-key navigation, like this. This would probably be the best approach, but is quite a bit of extra work and would require a custom implementation

Do you have any other ideas how to make these items keyboard-accessible? I might be missing something.

As an aside, I was looking for comps in other products to see what they did. The ones I checked (Datadog and Amplitude) unfortunately are not keyboard accessible in their collapsed state 😞)

Also, when trying to get into it with the mouse, I managed to get it to close before moving the mouse into it a bunch of times, which was a bit frustrating:

Ah yes agree that's the the best behavior. Removed the offset so there is no room for the menu to be dismissed in between the trigger and overlay.

… better scroll behavior but remove elements from tab order
@malwilley
Copy link
Member Author

@TkDodo I'm going to merge this because I want to get some feedback on the UX before we start pushing to GA soon, but the keyboard accessibility is still on my mind so feel free to leave more comments or reach out if you have suggestions

@malwilley malwilley merged commit 98e9897 into master May 22, 2025
42 checks passed
@malwilley malwilley deleted the malwilley/feat/nav-hover-section branch May 22, 2025 20:46
@TkDodo
Copy link
Contributor

TkDodo commented May 23, 2025

@malwilley have a look at how react-aria does sub-menus:

https://react-spectrum.adobe.com/react-aria/Menu.html#submenus

It has keyboard navigation, fault tolerance and other goodies built in: https://react-spectrum.adobe.com/blog/creating-a-pointer-friendly-submenu-experience.html

since we already use react-aria heavily, I think our menus should be built on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants