react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

The Reach Menu isn't being triggered inside a React Aria Dialog.

Open carlrobert-l opened this issue 1 year ago โ€ข 1 comments

Provide a general summary of the issue here

We recently started using the react-aria library for our overlays, and this has caused a bug that prevents the Reach menus from being triggered in the dialogs. The issue arises because the menus are rendered within portals, and my best guess is that react-aria maintains a focus lock on elements outside of the currently active overlay element.

Any ideas how to solve this?

๐Ÿค” Expected Behavior?

The menu can be opened in the modal/dialog.

๐Ÿ˜ฏ Current Behavior

Menu list is not visible after clicking on a menu button.

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

https://codesandbox.io/p/devbox/jrt8hx

Version

latest

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Mac OS X

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

carlrobert-l avatar Jan 18 '24 13:01 carlrobert-l

This is a tough one since many of our overlays manage/trap focus within themselves as you've discovered for accessibility reasons. Usually child overlays would be registered as child FocusScopes and thus focus could move from a parent overlay into the child overlay but this relies on said child calling/using FocusScope. 3rd party overlays won't do this by default of course and may have their own focus management that may clash with our own. We've discussed in the team in the past about perhaps allowing users to disable our focus management or register arbitrary elements as "ok to focus" but didn't land on anything yet. I don't suppose you can control where the Reach Menu gets portalled to?

LFDanLu avatar Jan 19 '24 17:01 LFDanLu