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

Update OverlayContainer to work in SSR

Open chrisdmacrae opened this issue 4 years ago • 8 comments

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:

  1. Make sure SSR works when OverlayContainer is present.
  2. Confirm that aria-hidden displays as expected with useModal

🧢 Your Project:

On behalf of chrisdmacrae.com

chrisdmacrae avatar Nov 05 '21 02:11 chrisdmacrae

Please advise on tests and checklist

chrisdmacrae avatar Nov 05 '21 02:11 chrisdmacrae

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.

snowystinger avatar Nov 05 '21 15:11 snowystinger

Any progress here?

sondretj avatar Apr 27 '22 08:04 sondretj

@sondretj totally forgot about this. I'll submit an update this week hopefully.

chrisdmacrae avatar Apr 27 '22 15:04 chrisdmacrae

@sondretj however I cannot get the CLA to work

chrisdmacrae avatar Apr 27 '22 15:04 chrisdmacrae

Closing and reopening fixed the CLA, you're good to go

snowystinger avatar Apr 27 '22 16:04 snowystinger

Any updates on this one? I'm facing this exact issue right now.

mdoliv avatar May 25 '22 20:05 mdoliv

@flayner2 can't get tests to pass

chrisdmacrae avatar May 28 '22 14:05 chrisdmacrae

I believe this issue has been fixed in the meantime. It now checks SSR during rendering.

devongovett avatar Mar 30 '23 19:03 devongovett