-
Notifications
You must be signed in to change notification settings - Fork 171
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
Refactor as an input for using isOpened correctly #51
Comments
I think I don't get it. What's the use case? Pull request? |
Don't have a PR yet. The use case is related to maybe
and you forget In controlled state, if you omit the But by default, the portal will not close up anymore if you use isOpened, user have to send isOpened to false for closing/opening logic to happen only in componentWillReceiveProps (and componentWillUnmount) via isOpened. Just like a controlled input. |
I get it know. This is a good idea. Yeah, it would be helpful to introduce the Also, the |
We thought about it with a colleague and we think that a small refactoring to work exactly as an input would be great.
If you do NOT use
isOpened
, the portal is in a non controlled state. You close it via the optional props. Nothing is different from before.If you DO use
isOpened
, the Portal enter controlled state.With the value prop of an input being equivalent to the
isOpened
prop of the portal andtoBeDefined
equivalent toonChange
(orbeforeClose
, not sure yet).Anything wanting to close the portal will declare its intent to close the portal, the user will catch that and be able to change its state correctly so that
isOpened
is false. But you do not actually edit the active state of the portal to false or do anything at all inside the portal, except declare your intent to close the portal (if usingcloseOnEsc
and pressing escape, you will trigger theonChange
equivalent, but the portal will not close unless the user re-renders withisOpened
to false or unmounts the Portal).And of course, we do not forget the warning in propTypes that
isOpened
MUST come with the portal equivalentonChange
prop.Thoughts ?
The text was updated successfully, but these errors were encountered: