tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Dialog.close() does not call the close callback #206

Closed Kassy2048 closed 1 year ago

Kassy2048 commented 1 year ago

Describe the bug. If a close callback (closeFn) has been given when calling Dialog.open(), that callback is not invoked when closing the dialog from code using Dialog.close(). The callback is only called when the user manually closes the dialog using mouse or keyboard.

To Reproduce:

  Dialog.setup("Test");
  Dialog.wiki('<<link "Click Me">><<set Dialog.close()>><</link>>');
  Dialog.open({}, () => {
    alert("Close callback called!");
  });

Expected behavior. Clicking the "Click Me" link should close the dialog and show the alert message. It only closes the dialog though, so the close callback is not called. Clicking on the "X" close button instead does invoke the callback.

Workaround.

  Dialog.setup("Test");
  Dialog.wiki('<<link "Click Me">><<set jQuery("#ui-dialog-close").trigger("click")>><</link>>');
  Dialog.open({}, () => {
    alert("Close callback called!");
  });

Project details.

tmedwards commented 1 year ago

It was the intended behavior, so not a bug.

Regardless. The behavior was changed, back in November 2022, via commit 96ddf9a to align with your feature request.

I'm closing this as redundant.

Kassy2048 commented 1 year ago

Aw sorry, I couldn't find a ticket or discussion about that behavior. Thanks for having changed it then 😁