react-spectrum
react-spectrum copied to clipboard
Update OverlayContainer to work in SSR
Currently if OverlayContainer is rendered during SSR it would fail because of trying to access document.body. This ensures that the window APIs are only called on the browser during useEffect, and only attempts to render the portal when it has a container
Closes https://github.com/adobe/react-spectrum/issues/1055
✅ Pull Request Checklist:
- [ ] Included link to corresponding React Spectrum GitHub Issue.
- [ ] Added/updated unit tests and storybook for this change (for new code or code which already has tests).
- [ ] Filled out test instructions.
- [ ] Updated documentation (if it already exists for this component).
- [ ] Looked at the Accessibility Practices for this feature - Aria Practices
📝 Test Instructions:
- Make sure SSR works when
OverlayContaineris present. - Confirm that aria-hidden displays as expected with useModal
🧢 Your Project:
On behalf of chrisdmacrae.com
Please advise on tests and checklist
hey @chrisdmacrae! thanks for taking a go at this. in order to verify/test this, you can probably utilize our SSR tests see https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/picker/test/Picker.ssr.test.js for an example
Right now all of our SSR tests are pretty basic, just check that the most basic set of props renders, but you might be able to toss an isOpen on the one i linked in a new it to check if your fix works.
Any progress here?
@sondretj totally forgot about this. I'll submit an update this week hopefully.
@sondretj however I cannot get the CLA to work
Closing and reopening fixed the CLA, you're good to go
Any updates on this one? I'm facing this exact issue right now.
@flayner2 can't get tests to pass
I believe this issue has been fixed in the meantime. It now checks SSR during rendering.