Skip to content

Commit

Permalink
fix(lib): restore onConfirm and onCancel
Browse files Browse the repository at this point in the history
- Restores the `onConfirm` and `onCancel` properties given to
  programmatic `Dialog.open` because I came up with a better workaround.
  `Dialog` continues to accept `confirmCallback` and `cancelCallback`
  instead of `onConfirm` and `onCancel` but `Dialog.open` forwards
  `confirmCallback` and `cancelCallback` calls to `propsData.onConfirm`
  and `propsData.onCancel` respectively.
  Restores also the `onCancel` property given to programmatic
  `Modal.open`. `Modal` still needs `cancelCallback` instead of
  `onCancel`.

issue kikuomax#4

Co-authored-by: kylejennings83 <kyle.jennings@traliant.com>
  • Loading branch information
kikuomax and kylejennings83 committed Jul 11, 2023
1 parent ee87084 commit 76b7b91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/components/dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,30 @@ function open(propsData) {
Dialog,
{
...propsData,
// intentionally overrides propsData.onConfirm
// to prevent propsData.onConfirm from receiving a "confirm" event
onConfirm: (...args) => {
if (onConfirm != null) {
onConfirm(...args)
}
},
// intentionally override propsData.onCancel
// to prevent propsData.onCancel from receiving a "cancel" event
onCancel: (...args) => {
if (onCancel != null) {
onCancel(...args)
}
vueInstance.unmount()
},
confirmCallback: (...args) => {
if (propsData.onConfirm != null) {
propsData.onConfirm(...args)
}
},
cancelCallback: (...args) => {
if (propsData.onCancel != null) {
propsData.onCancel(...args)
}
}
},
slot ? { default: () => slot } : undefined
Expand Down
8 changes: 8 additions & 0 deletions src/components/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const ModalProgrammatic = {
...propsData,
onClose: () => {
vueInstance.unmount()
},
// intentionally overrides propsData.onCancel
// to prevent propsData.onCancel from receiving a "cancel" event
onCancel: () => {},
cancelCallback: (...args) => {
if (propsData.onCancel != null) {
propsData.onCancel(...args)
}
}
},
slot ? { default: () => slot } : undefined
Expand Down

0 comments on commit 76b7b91

Please sign in to comment.