Closed patricklafrance closed 1 year ago
This seems like it is because Select has preserveChildren set to true, causing the child Popover to render its children even when the state is closed. Usually this isn't a problem, but OverlayArrow expects to receive arrowProps from a context that only is available when the Popover is actually open. We should add a || {}
or make sure that the OverlayArrowContext is available if preserveChildren
is true
is there a workaround for this issue?
@ealvarezk you could try leveraging the Select's isOpen
renderProps to conditionally render the OverlayArrow perhaps.
<Select>
{({isOpen}) => (
<>
<Label style={{display: 'block'}}>Test</Label>
<Button>
<SelectValue />
<span aria-hidden="true" style={{paddingLeft: 5}}>{isOpen ? 'β²' : 'βΌ'}</span>
</Button>
<Popover>
{isOpen && (
<OverlayArrow>
<svg width={12} height={12}><path d="M0 0,L6 6,L12 0" /></svg>
</OverlayArrow>
)}
<ListBox className={styles.menu}>
<MyItem>Foo</MyItem>
<MyItem>Bar</MyItem>
<MyItem>Baz</MyItem>
</ListBox>
</Popover>
</>
)}
</Select>
Otherwise this would require changes in the OverlayArrow code like I mentioned above (aka adding a fallback like || {arrowProps: {style: {top: 0}}
)
π Bug Report
I copy/pasted the Select components "Reusable Wrappers" example of React-Aria component in my project and I get the following error at runtime:
Copy pasted the "Reusable Wrapper" exemple and then using it like this (I renamed
MyItem
toMySelectItem
):π€ Expected Behavior
No error at runtime.
π― Current Behavior
π Possible Solution
π¦ Context
π» Code Sample
Here a Github repository with the code: https://github.com/patricklafrance/next13-react-aria/blob/main/app/react-aria/MySelect.tsx
Uncomment the following code in
app/react-aria/page.tsx
:π Your Environment
π§’ Your Company/Team
π· Tracking Issue (optional)