question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to perform action on modal open?

See original GitHub issue

It 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:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thesunnycommented, Aug 28, 2015

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

0reactions
claydiffrientcommented, Dec 26, 2016

Closing because #154 was released.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found