You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello and thank you for your work. This library has been of great help to me.
Use case
I'm using react-aria-menubutton to help me handle keyboard navigation in my forms. One of them lives inside a modal. When the modal is open, I want my menu to be visible immediately, without having to trigger it by pressing a button.
What I tried
Passing isOpen
The type definitions say I could pass isOpen to Wrapper.
This doesn't seem to be the case. React passes that prop down to the underlying div and displays a warning.
Warning: React does not recognize the `isOpen` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `isopen` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Passing open
The type definitions allow me to pass a prop called open, but it doesn't come directly from WrapperProps. It's inherited from AllHTMLAttributes<T> and has no effect.
Using openMenu
When I add an id=menu to my Wrapper and try to open the menu programmatically, I get a runtime exception.
I'm using a function component. It doesn't matter if I use useEffect or useLayoutEffect to run the effect — at the time they're executed, my menu hasn't mounted yet, and an element of id=menu doesn't exist.
I tried providing a ref to Wrapper and calling openMenu only when I know the underlying HTMLElement is mounted, but unfortunately Wrapper doesn't forward React refs. The only workaround that seems to be working is to do:
Hello and thank you for your work. This library has been of great help to me.
Use case
I'm using
react-aria-menubutton
to help me handle keyboard navigation in my forms. One of them lives inside a modal. When the modal is open, I want my menu to be visible immediately, without having to trigger it by pressing a button.What I tried
Passing
isOpen
The type definitions say I could pass
isOpen
toWrapper
.https://github.com/DefinitelyTyped/DefinitelyTyped/blob/ec03e77d0a0c84d599b46211befac932160d5a0f/types/react-aria-menubutton/index.d.ts#L44
This doesn't seem to be the case. React passes that prop down to the underlying
div
and displays a warning.Passing
open
The type definitions allow me to pass a prop called
open
, but it doesn't come directly fromWrapperProps
. It's inherited fromAllHTMLAttributes<T>
and has no effect.Using
openMenu
When I add an
id=menu
to myWrapper
and try to open the menu programmatically, I get a runtime exception.I'm using a function component. It doesn't matter if I use
useEffect
oruseLayoutEffect
to run the effect — at the time they're executed, my menu hasn't mounted yet, and an element ofid=menu
doesn't exist.I tried providing a
ref
toWrapper
and callingopenMenu
only when I know the underlying HTMLElement is mounted, but unfortunatelyWrapper
doesn't forward React refs. The only workaround that seems to be working is to do:which works, but because it relies on a low-level DOM API, it goes against the declarative model of React.
The question
How can I render my menu open from the start?
Related
isOpen
via external controls. #48 suggestsWrapper
should acceptisOpen
isOpen
is not meant to manipulate state and mentionsstartOpen
that doesn't exist todayThe text was updated successfully, but these errors were encountered: