How to perform action on modal open?
See original GitHub issueIt seems that with the isOpen
api, neither componentDidMount
nor componentDidUpdate
actually guarantee the modal is open, even when making sure props.isOpen is set. I’m not sure what causes the delay, but if I want to do something like focus an input on modal open, I can’t do it because the modal isn’t visible yet.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Calling a function on Bootstrap modal open - Stack Overflow
You can use the shown event/show event based on what you need: $( "#code" ).on('shown', function(){ alert("I want this to appear after the...
Read more >Modal - Bootstrap
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open to the <body> to override...
Read more >trigger a bootstrap modal show event - jQuery Forum
show.bs.modal is an event that the Bootstrap modal code itself triggers when the show function is called. It allows YOUR code to do...
Read more >Bootstrap JS Modal Reference - W3Schools
The Modal plugin is a dialog box/popup window that is displayed on top of the current page. For a tutorial about Modals, read...
Read more >How to perform action from form opened in modal?
Step 2: Create the form that will open when the #url is called and create a route for it as well. Remember to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for putting this React Modal together. Really nice.
I think this and the issue on focus can be handled by having an onAfterOpen callback passed in as a prop. This way, after the modal is open, we can perform an action on open which includes the ability to set the focus.
My feeling is that it may be beneficial to remove the auto-focus since it’s not necessary in a lot of cases and in cases where you want it, you can easily add focus through the onAfterOpen callback. In any case, if you do keep it, just a reminder to make sure the autofocus happens before the onAfterOpen callback or else any focus set in the callback would be lost.
Would also solve the following issue: https://github.com/rackt/react-modal/issues/51
Closing because #154 was released.