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

Modal component to update props when it receive new ones and fix erro… #507

Merged
merged 4 commits into from
Oct 30, 2018

Conversation

stefaniacardenas
Copy link
Contributor

@stefaniacardenas stefaniacardenas commented Oct 29, 2018

Problem

  • When using the option useModal: true, react-modal returns Uncaught Error: react-modal: You must set an element with Modal.setAppElement(el) to make this accessible
    You can see the error here https://jsfiddle.net/4xqtt6fL/1698/
  • The isModalOpen option was not properly received by the Modal component and this was causing issues when trying to close the modal using the close button.

Solution

  • Pass appElement={document.body} to the react-modal component so it knows which element should be hidden from screen readers when the modal is open.
  • Use componentWillReceiveProps(nextProps) {...} to update the state of the Modal

Checklist

put n/a if item is not relevant to PR changes

  • Have the CHANGELOG, README, MIGRATION, RELEASE_GUIDELINES docs been updated?
  • [n/a] Have new automated tests been implemented?
  • [n/a] Have new manual tests been written down?
  • Have tests passed locally?
  • [n/a] Have any new strings been translated?

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-507-pr-onfido-sdk-ui-onfido.surge.sh

MIGRATION.md Outdated
// callback for when everything is complete
console.log("everything is complete")
},
steps: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: to keep the migration more focused you can remove the steps and let it default

README.md Outdated
// callback for when everything is complete
console.log("everything is complete")
},
steps: [
Copy link
Contributor

@rfreitas rfreitas Oct 29, 2018

Choose a reason for hiding this comment

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

you can drop steps from here too.
on a side note: I'm a bit hesitant with adding long examples to side features. My fear is the readme can grow quite large

portalClassName={style.portal}
overlayClassName={style.overlay}
bodyClassName={style.modalBody}
className={style.inner}
shouldCloseOnOverlayClick={true}
closeTimeoutMS={MODAL_ANIMATION_DURATION}
ariaHideApp={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It prevents react-modal from throwing You must set an element with Modal.setAppElement(el) to make this accessible. Thinking about it, this is probably not the best way of fixing the error because this will make the content behind the modal readable by screen readers. There is another fix and it involves passing appElement={document.body} or appElement={document.getElementById('onfido-mount')}. I think this is a better solution because it doesn't break screen readers. See discussion here reactjs/react-modal#576

Copy link
Contributor

@rfreitas rfreitas left a comment

Choose a reason for hiding this comment

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

added some comments on documentation

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-507-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://507-pr-onfido-sdk-ui-onfido.surge.sh

@seewah seewah merged commit 7d478e0 into release/3.0.0 Oct 30, 2018
@josokinas josokinas deleted the bug/fix-modal-issues-cx-2683 branch July 10, 2020 14: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