-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Modal: Better uncontrolled usage support #891
Comments
Agreed!
I'm less fond of adding to the Portal, since these seem like specialized use cases rather than true Portal features, IMO. What if instead, we provided some props for configuring the Modal buttons (actions)? There are only so many common "sets" of buttons you'd want, I think. For example, something like:
If that is true, then we could provide shorthand props for individual buttons, or an array of butons: <Modal leftAction={{ content: 'OK', primary: true }} rightAction='Cancel' />
// or
<Modal actions={[{ content: 'OK', primary: true }, 'Cancel']} |
@levithomason - check the related PR (#893). I think it solves the problem pretty elegantly and enables a lot more flexibility. Given that we don't currently support any shorthand for |
Closing for #1599. |
The SUI-core Modal supports various options for closing. See the "DOM Settings" section here: http://semantic-ui.com/modules/modal.html#settings
The following actions are called onClick of something matching the associated selector:
close
just closes the modalapprove
callsonApprove
and closes the modal unless the return value fromonApprove
isfalse
deny
callsonDeny
and closes the modal unless the return value fromonDeny
isfalse
.This could be possible by attaching a click listener to the modal content and checking the
currentTarget
for one of these classes or perhaps adata-(close|approve|deny)
attribute. This doesn't really feel very React-y, so open to other suggestions but I really think we should support something like this. Currently there's no way to:Confirm
component without managingopen
state yourself.X
to close aModal
without wiring it to some state you're managing outside.IMHO the most common use-cases for all of our components should be handled out of the box without the need to wrap things yourself.
One issue I see is that the modal technically doesn't manage
open
state, thePortal
does. So we'd either have to:Portal
which feels kinda wrongModal
into anAutoControlled
component and have it manage it's ownopen
state and pass it toPortal
. From a user perspective, I don't think anything would change, we'd just have some duplicative functionality.We could also forego the approve/deny functionality and add a
closeOnCloseClick
prop toPortal
which would cause it to close if something with thedata-close
attribute was clicked within thePortal
. I actually think that would be pretty reasonable.Thoughts?
The text was updated successfully, but these errors were encountered: