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

[EuiOverlayMask] Fix document is undefined #5422

Merged
merged 9 commits into from
Dec 3, 2021
Merged

[EuiOverlayMask] Fix document is undefined #5422

merged 9 commits into from
Dec 3, 2021

Conversation

jeepers3327
Copy link
Contributor

@jeepers3327 jeepers3327 commented Nov 30, 2021

Summary

This fixes #4807 which causes ReferenceError: document is not defined error. The code that I add is to check whether the document is defined before appending the overlay mask component to the document body.

demo

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link

cla-checker-service bot commented Nov 30, 2021

💚 CLA has been signed

@miukimiu
Copy link
Contributor

Hi @jeepers3327 👋🏽 ,

Thank you for opening this PR to fix the issue #4807.

Could you please sign the Contributor Agreement so we can review your PR?

@jeepers3327
Copy link
Contributor Author

jeepers3327 commented Nov 30, 2021

Hello @miukimiu ,

I've already signed the Contributor Agreement. Thanks.

@miukimiu
Copy link
Contributor

Thanks @jeepers3327. One of ours engineers will do the review. 🎉

In the meantime, can you go through the PR checklist? For example, a changelog entry is missing. 🙂

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

This does cover cases where EuiOverlayMask is hidden to start, but there is still a document error if the component is shown to start:

Screen Shot 2021-11-30 at 12 02 04 PM

The node creation point needs to be adjusted, as well. It may need to be moved inside the useEffect in cases where SSR is used:

const overlayMaskNode = useRef<HTMLDivElement>(document.createElement('div'));

@hetanthakkar

This comment has been minimized.

@jeepers3327
Copy link
Contributor Author

This does cover cases where EuiOverlayMask is hidden to start, but there is still a document error if the component is shown to start:

Screen Shot 2021-11-30 at 12 02 04 PM

The node creation point needs to be adjusted, as well. It may need to be moved inside the useEffect in cases where SSR is used:

const overlayMaskNode = useRef<HTMLDivElement>(document.createElement('div'));

I fixed the issue by setting the overlayMaskNode inside useEffect (985633b)
overlay

@thompsongl
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5422/

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

This looks ready to merge after the changelog update and the one suggestion below

src/components/overlay_mask/overlay_mask.tsx Outdated Show resolved Hide resolved
@jeepers3327
Copy link
Contributor Author

I've applied the suggested code and move the changelog entry on the top portion of the document.

Just a question, do I have to added any dependencies in @elastic/eui since I get this error during git commit.

● Validation Error:

  Module @emotion/jest/enzyme-serializer in the snapshotSerializers option was not found.
         <rootDir> is: /home/hei/contribute/eui

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
child_process.js:866
    throw err;

This wasn't present during my PR and commits.

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Just a question, do I have to added any dependencies

Try running yarn install if you haven't in a couple days

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@thompsongl
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5422/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@thompsongl thompsongl merged commit 7715da3 into elastic:main Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiCollapsibleNav] document is not defined when using CollapsibleNav
7 participants