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

Can't display Modal programmatically #6980

Closed
2 tasks done
NourEldinShobier opened this issue Oct 6, 2020 · 5 comments
Closed
2 tasks done

Can't display Modal programmatically #6980

NourEldinShobier opened this issue Oct 6, 2020 · 5 comments

Comments

@NourEldinShobier
Copy link

What package(s) are you using?

  • carbon-components
  • carbon-components-react

Summary

Can't trigger ModalWrapper to display the modal remotely.

Relevant information

My ModalWrapper holds a form for adding/editing courses, and I have two buttons:

  • one for adding courses - default ModalWrapper button -
  • another for editing
    I tried to trigger click event of the ModalWrapper button to display the modal by calling document.getElementById('formModal').click(); when user clicks the edit button but it didn't work.
@tw15egan
Copy link
Member

tw15egan commented Oct 6, 2020

Can you recreate your issue on CodeSandbox so we can assist in debugging?

@NourEldinShobier
Copy link
Author

Here it's https://codesandbox.io/s/vigilant-dream-e3m1e?file=/src/index.js .... I want to be able to show the modal and fill the form when the selected course edit button is clicked

@asudoh
Copy link
Contributor

asudoh commented Oct 7, 2020

Weighing in; <Modal> or <ComposedModal> serves the exact purpose here, they can be controlled by open prop. I believe @emyarod has had a doc updated around this topic.

@emyarod
Copy link
Member

emyarod commented Oct 7, 2020

yes, I would recommend using Modal or ComposedModal and essentially implementing your own version of ModalWrapper (which was only meant to be an example rather than an exported component). currently I am looking to deprecate ModalWrapper and replace it with a similar storybook example. #6806 is the WIP draft to update the ModalWrapper docs

@NourEldinShobier
Copy link
Author

Thank you so much =D

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

No branches or pull requests

4 participants