-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat(NcModal): Allow to configure if the modal is closed when clicked outside #4454
feat(NcModal): Allow to configure if the modal is closed when clicked outside #4454
Conversation
… outside Currently the modal is closed if `canClose` is `true` and the user clicked outside the modal on the backdrop. This can now be configured with the `closeOnClickOutside` property (defaults to `true` for backwards compatibility). Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition :)
Code looks good but I'm testing this in the docs and adding close-on-click-outside="false"
doesn't work. Am I missing something?
No voko.mp4 |
/** | ||
* Close the modal if the user clicked outside of the modal | ||
* Only relevant if `canClose` is set to true. | ||
*/ | ||
closeOnClickOutside: { | ||
type: Boolean, | ||
default: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a standard form of passing props Vue enforces HTML standard aka:
<input /> <!-- enabled-->
<input disabled /> <!-- disabled -->
But boolean props with default true
requires to always use longhand form over HTML Standard:
<NcModal /> <!-- closes on click -->
<NcModal close-on-click-outside /> <!-- also closes on click, passing bool prop does nothing -->
<NcModal :close-on-click-outside="false" /> <!-- changes behavior, doesn't close on click -->
<NcModal close-on-click-outside="false" /> <!-- casts string "false" to true and closes on click -->
because of that it is usually recommended to make bool props with false
default value:
<!-- With default false boolean prop -->
<NcModal /> <!-- closes on click -->
<NcModal ignore-click-outside /> <!-- changes behavior, doesn't close on click -->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :)
I know but did not wanted to make this a breaking change by changing the default behavior and a negated property seems to be confusing.
Maybe we can risk another breaking change?
☑️ Resolves
Currently the modal is closed if
canClose
istrue
and the user clicked outside the modal on the backdrop. This can now be configured with thecloseOnClickOutside
property (defaults totrue
for backwards compatibility).This is especially helpful for implementing the dialogs.
🏁 Checklist