Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed SSR error in Menu #16559

Merged
merged 3 commits into from
Jun 17, 2024
Merged

Conversation

guidari
Copy link
Contributor

@guidari guidari commented May 23, 2024

Closes #15531
Closes #16004
Closes #16251

We are adding a checker to handle the document.body to avoid error when using SSR if the document is not rendered.
Also we have to guard if the target is undefined, because createPortal does not accept an undefined element

For some reason the eslint still yelling about the SSR, I tried multiple ways of guarding that. The first commit uses the useIsomorphicEffect but it was broking the tests.
But I would like to check with the usesr having this problem, to see if this would fix it. Or I can try to create a quick demo, if there is time, to see if that works before releasing.

Testing / Reviewing

  • Check if the components that uses Menu are working as expected.

@guidari guidari requested a review from a team as a code owner May 23, 2024 16:39
Copy link

netlify bot commented May 23, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 17eb52a
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/667049f0d0d7d60008583563
😎 Deploy Preview https://deploy-preview-16559--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 23, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 17eb52a
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/667049f09c90fe000813cc15
😎 Deploy Preview https://deploy-preview-16559--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@Gururajj77 Gururajj77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small question, why do we change the target to element from HTMLElement? is it because it won't be recognised as DOM element on server?

@guidari
Copy link
Contributor Author

guidari commented May 23, 2024

One small question, why do we change the target to element from HTMLElement? is it because it won't be recognised as DOM element on server?

No, actually we could kept the HTMLElement, i just changed to match exactly what is typed in the createPortal function

export function createPortal(children: ReactNode, container: Element, key?: null | string): ReactPortal;

Copy link
Member

@alisonjoseph alisonjoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@guidari guidari added this pull request to the merge queue Jun 17, 2024
Merged via the queue into carbon-design-system:main with commit 6cbcba7 Jun 17, 2024
22 checks passed
@guidari guidari deleted the 15531-nextjs branch June 17, 2024 16:41
@carbon-automation
Copy link
Contributor

Hey there! v11.60.0 was just released that references this issue/PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants