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

Deprecate isOpen #25

Closed
srph opened this issue Mar 27, 2015 · 8 comments
Closed

Deprecate isOpen #25

srph opened this issue Mar 27, 2015 · 8 comments

Comments

@srph
Copy link

srph commented Mar 27, 2015

I find this more convenient compared to the current approach.

{ condition ? (
<Modal
  onRequestClose={fn}
  closeTimeoutMS={n}
>
  <h1>Modal Content</h1>
  <p>Etc.</p>
</Modal>
) : null }

However, I haven't tried this (whether is works), and I do not acknowledge any pros and cons of the approach besides a cleaner API.

@cameronsutter
Copy link

I've also found it to be more convenient this way

@pstoica
Copy link

pstoica commented Apr 23, 2015

I think you'd lose out on being able to animate? I don't think you can wrap <Modal> in something like ReactTransitionGroup since it needs to open up through another portal.

@srph
Copy link
Author

srph commented Oct 30, 2015

@pstoica Yea. I just realized this. Closing this because I just made myself look stupid 🎉 haha

@srph srph closed this as completed Oct 30, 2015
@yvele
Copy link

yvele commented Mar 7, 2017

@pstoica @srph @monsieurnebo @diasbruno So basically the whole point of isOpen is to allow animations through ReactTransitionGroup ?

If I don't have animation, can you confirm that no using isOpen and returning null (no render atl all) is straightforward and well.. better.

What the point of the portal? Only animation or is there some a11y magic?

Related to #205

@diasbruno
Copy link
Collaborator

The Modal.js is responsible for setting all the environment (specially a11y, toggle the body class...). It also contains the timer for the animation since it doesn't uses css events to control its state.

@yvele Can you elaborate your idea to handle this?

Resources:
Modal.js#L81
Modal.js#L110
Modal.js#L117

@neptunian
Copy link

neptunian commented Jul 27, 2017

@yvele @diasbruno i modified the library a bit and not using isOpen works fine but then you lose out on animation. The reason I did it is because if i use the library, as is, I can't get react-router to work properly where i render a component based on a route. In my app the modals have urls and it seems react-modal is designed to be mounted when the page loads and show or hides the modal based on the isOpen prop instead of mounting and unmounting the whole component based on a route. I think it'd be better to get rid of the isOpen prop but i don't know how you'd handle animation then. I was not able to figure that part out, but i imagine there must be some other way to handle animations.

@yvele
Copy link

yvele commented Jul 27, 2017

@monsieurnebo CC

@neptunian
Copy link

I believe i've been able to get it working without having to remove isOpen with react-router by using the children function:
https://reacttraining.com/react-router/web/api/Route/children-func

That way the component mounts no matter what and the modal can continue using isOpen with animation.

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

6 participants