Skip to content

[EuiOverlayMask] Fix document is undefined - #5422

Merged
thompsongl merged 9 commits into
elastic:mainfrom
jeepers3327:main
Dec 3, 2021
Merged

thompsongl merged 9 commits into
elastic:mainfrom
jeepers3327:main

Conversation

@jeepers3327

@jeepers3327 jeepers3327 commented Nov 30, 2021 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

cla-checker-service Bot commented Nov 30, 2021 •

Copy link
Copy Markdown

💚 CLA has been signed

@elizabetdev

Copy link
Copy Markdown
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

jeepers3327 commented Nov 30, 2021 •

Copy link
Copy Markdown
Contributor Author

Hello @miukimiu ,

I've already signed the Contributor Agreement. Thanks.

@elizabetdev

Copy link
Copy Markdown
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. 🙂

@thompsongl thompsongl left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

jenkins test this

@kibanamachine

Copy link
Copy Markdown
Contributor

Comment thread CHANGELOG.md Resolved

@thompsongl thompsongl left a comment

Copy link
Copy Markdown
Contributor

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

@jeepers3327

Copy link
Copy Markdown
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.

@thompsongl thompsongl left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
@thompsongl

Copy link
Copy Markdown
Contributor

jenkins test this

@kibanamachine

Copy link
Copy Markdown
Contributor

@chandlerprall chandlerprall left a comment

Copy link
Copy Markdown
Contributor

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
@thompsongl thompsongl mentioned this pull request Dec 9, 2021
1 task done
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