Closed gregberns closed 7 years ago
In this next release tonight:
Your onDismiss
was added, but there is a better way to do this. All methods now return a Promise
. So the callbacks can be omitted ie:
this.dialogbox.pop({
title: 'Animals',
content: 'Which animal do you like?',
btns: [
{
text: 'Frog'
},
{
text: 'Dog'
},
{
text: 'Cat'
}
]
}).then(event => {
if (event.button) {
this.dialogbox.alert([
`You selected ${event.button.text}`,
`It was button index ${event.index}`
]);
} else {
this.dialogbox.alert([
'Dialog was dismissed without selection',
'Index for this event is always -1'
]);
}
});
The original way you are working with it will work as well. Would love to hear which one you prefer.
The dialog box component allows the pop up do be dismissed without actually making a selection (isOverlayClickClose). If the user can dismiss the dialog box I want to know that they did.
Thes PR simply adds a 'onDismiss' parameter that allows the developer to hook in and call a function when its dismissed.