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

Fix modal warning in console and tests #381

Merged
merged 2 commits into from
Feb 16, 2018
Merged

Conversation

lauraxm
Copy link

@lauraxm lauraxm commented Feb 14, 2018

Description of changes introduced:
The following warning is shown in both the console and the e2e test output:

react-modal: App element is not defined. Please useModal.setAppElement(el)or setappElement={el}. This is needed so screen readers don't see main content when modal is opened. It is not recommended

This fix will set the element before the render with componentWillMont()

A few references:
reactjs/react-modal#133
https://stackoverflow.com/questions/48269381/warning-react-modal-app-element-is-not-defined-please-use-modal-setappeleme
reactjs/react-modal#576

@@ -10,6 +10,11 @@ Modal.defaultStyles.content.zIndex = 2
Modal.defaultStyles.overlay.zIndex = 2

export class Alert extends Component {

componentWillMount() {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be set in componentWillMount? could we set it after the zIndex assignments on line 9 and 10?

Copy link
Contributor

Choose a reason for hiding this comment

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

also, i think the app element might be selected via .react-root, rather than body, as that's the div that our react app mounts to

Copy link
Author

Choose a reason for hiding this comment

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

Yes, we can set it after the zIndex and it works.

So I tried setting it to .react-root but the alert-tests fail, and I'm not entirely sure why. Example of one failure:

Alert component
       "before each" hook for "renders the headerText in a header text component":
     Error: react-modal: No elements were found for selector .remote-root.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.703% when pulling 3234ab4 on fix-react-modal-warning into 64fc68f on master.

@vanderhoop
Copy link
Contributor

woot!

@vanderhoop vanderhoop merged commit e49b7d2 into master Feb 16, 2018
@vanderhoop vanderhoop deleted the fix-react-modal-warning branch February 16, 2018 15:09
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.

3 participants