Skip to content

fix(react-nav): Inset focus outlines to fix focus borders being cut off. #34603

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 3 commits into from
Jun 9, 2025

Conversation

emmayjiang
Copy link
Contributor

Previous Behavior

The original focus outline fix changed two things:

  • Added a 2px top margin to AppItems, and added a -2px top margin to the drawer header.
  • Added zIndex to NavItem focus and active states

Neither of these behaviors are ideal, unfortunately. If for example a partner wants to include more than one AppItem inside their Nav, they would have an extra 2px margin on their second AppItem. If they didn't want to include an AppItem or wanted to add it somewhere besides the top of the Nav, the first item in the Nav would be cut off.

For the added zIndex: as Mason said, we don't want to bake in z indexes to shared components because product code often has their own z indexing strategy that can clash with ours.

New Behavior

A safer approach with less potential impact to partners to fixing the issue of focus border being cut off would be to make the focus borders inset instead. This way there is lower impact to customers who want to use controls differently than the way they are set up in the storybook. We have used the inset focus outline approach in the Fluent AI CopilotNav as well as other similar controls.

imageimage

Related Issue(s)

@emmayjiang emmayjiang requested review from mltejera and a team as code owners June 6, 2025 17:26
Copy link

github-actions bot commented Jun 6, 2025

📊 Bundle size report

✅ No changes found

Copy link

github-actions bot commented Jun 6, 2025

Pull request demo site: URL

Copy link
Contributor

@smhigley smhigley left a comment

Choose a reason for hiding this comment

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

I like this approach! We've also used outlineOffset in other controls for the same reason (e.g. TableRow), so it feels like a good fit for the pattern

@marcosmoura marcosmoura merged commit 1dc6622 into microsoft:master Jun 9, 2025
13 of 15 checks passed
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.

3 participants