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

[chore] Update doc to inform v3 users about close transition #672

Merged
merged 2 commits into from
Aug 28, 2018

Conversation

hoodwink73
Copy link
Contributor

Does not fix any issue. But informs the user about the discussion in #530

Changes proposed:

  • Update to documentation. Inform users of v3 be aware that close transition does not work with conditional render

@coveralls
Copy link

coveralls commented Jun 29, 2018

Coverage Status

Coverage remained the same at 87.703% when pulling edfd2a9 on hoodwink73:master into c3e06ab on reactjs:master.

@diasbruno
Copy link
Collaborator

Thanks, @hoodwink73. I'll have a look on your PR later.


The above example will apply the fade transition globally, affecting all modals
whose `afterOpen` and `beforeClose` classes have not been set via the
`className` prop. To apply the transition to one modal only, you can change
the above class names and pass an object to your modal's `className` prop as
described in the [previous section](classes.md).

In order for the close transition to take effect, you will also need to pass
the `closeTimeoutMS={150}` prop to each of your modals.
Copy link
Collaborator

@diasbruno diasbruno Jul 1, 2018

Choose a reason for hiding this comment

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

Maybe this can be rephrased, something like: The close animation is controlled via timer which you can define using closeTimeoutMS={number}, where the value is the time interval in milliseconds. The value must be synchronized with the css transition you have specified.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is explicit and better. I will update this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, also this part:

The value must be synchronized with the css transition or style you have specified (because styles can also be used in react-modal).


Also, if you are using `v3` which supports **React 16**, the close transition works [only if you use](https://github.com/reactjs/react-modal/issues/530#issuecomment-335208533) the `isOpen` prop to toggle the visibility of the modal.

Do not conditionally render the `<Modal />`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we need to elaborate here because it works for react 15, but not in 16 (if I remember correctly).

It seems that the conditional rendering in react 16+ will destroy the rendered elements unconditionally (seems the reason why it isn't work anymore). So, we probably hold the reference for the modal DOM tree, but it's not attached to any other element (this needs to be confirmed).

Copy link
Collaborator

Choose a reason for hiding this comment

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

The example is really awesome. 👍

Copy link
Contributor Author

@hoodwink73 hoodwink73 Jul 1, 2018

Choose a reason for hiding this comment

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

I am also not sure of why it does not work in React 16+ but in React 15. I will try to take a look at your suggestion of holding reference to the tree and try to come up with an explanation. Thanks for the hint.

Copy link
Contributor Author

@hoodwink73 hoodwink73 Jul 2, 2018

Choose a reason for hiding this comment

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

Does this look like a legit explanation to you regarding the limitation to control the unmounting of Portal?
facebook/react#10826

And this leads to the conditional rendering of <Modal /> not working.

I will try to do some debugging and experiment here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! This can be included in the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also answer #530, depending on the conclusion of your investigation and eventually close the issue. I'll continue to follow this and try to help where I can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Thanks.

>
<h2>Add modal content here</h2>
</Modal>
: null
Copy link
Collaborator

Choose a reason for hiding this comment

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

: null can be removed.

@diasbruno diasbruno changed the title Update doc to inform v3 users about close transition [chore] Update doc to inform v3 users about close transition Jul 4, 2018
@hoodwink73
Copy link
Contributor Author

@diasbruno hey I did some debugging and figured out concrete reasons why conditional rendering is not working in React 16.

I will add this to the opened issue.

Thanks a lot for all help. Have a great weekend.

@diasbruno
Copy link
Collaborator

diasbruno commented Aug 28, 2018

Thank you so much. Great effort on getting this, @hoodwink73.

@diasbruno diasbruno merged commit 921358e into reactjs:master Aug 28, 2018
@hoodwink73
Copy link
Contributor Author

🙌

I also posted a lengthy comment on #530 regarding my debugging efforts. It might help you to close the issue.

@diasbruno
Copy link
Collaborator

Yeah, that was great. That should clarify what is going on. Great job.

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