Skip to content

Commit

Permalink
fix(Menu): return focus to trigger after closing menu (#550)
Browse files Browse the repository at this point in the history
## 📝 Changes

- uses `Overlay` instead of `OverlayContainer` to return focus back to
trigger after closing menu. this is per Aria documentation and was
simply missed in the implementation
- attempted to write a unit test for this but couldn't get user event,
jsdom, and Aria to play nicely together for this change. will come back
to it when i figure out how to test focus in these cases

## ✅ Checklist

- [x] Code is complete and in accordance with our style guide
- [x] Ensure no accessibility violations are reported in Storybook
- [x] Cross-browser check is performed (Chrome, Safari, Firefox)
- [x] Changeset is added
  • Loading branch information
stephenjwatkins authored Aug 24, 2023
1 parent 8fe2ca9 commit 9089d64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-beans-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@easypost/easy-ui": patch
---

fix(Menu): return focus to trigger after closing menu
6 changes: 3 additions & 3 deletions easy-ui-react/src/Menu/MenuOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CollectionChildren } from "@react-types/shared";
import React, { Key } from "react";
import {
DismissButton,
OverlayContainer,
Overlay,
Placement,
mergeProps,
useMenu,
Expand Down Expand Up @@ -119,7 +119,7 @@ function MenuOverlayContent<T extends object>(props: MenuOverlayProps<T>) {
} as React.CSSProperties;

return (
<OverlayContainer>
<Overlay>
<div {...underlayProps} className={styles.underlay} />
<div
{...mergeProps(popoverProps, { style })}
Expand Down Expand Up @@ -155,6 +155,6 @@ function MenuOverlayContent<T extends object>(props: MenuOverlayProps<T>) {
</div>
<DismissButton onDismiss={menuTriggerState.close} />
</div>
</OverlayContainer>
</Overlay>
);
}

0 comments on commit 9089d64

Please sign in to comment.