From 0d8b1ef9ad936b360429708de3d748b4cfd23b45 Mon Sep 17 00:00:00 2001 From: ch0c0l8ra1n <073bct532.rajat@pcampus.edu.np> Date: Sun, 21 Apr 2024 23:28:08 +0545 Subject: [PATCH 1/5] Serve swalservice.js instead of swalservice.min.js --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 4530f76..0bc4f83 100644 --- a/R/utils.R +++ b/R/utils.R @@ -23,7 +23,7 @@ getDependencies <- function() { version = "1.0.0", package = "shinyalert", src = "assets/lib/swalservice", - script = "swalservice.min.js" + script = "swalservice.js" ), htmltools::htmlDependency( name = "shinyalert-binding", From ac3d2cbcb931ceddc5cc2cfe57478485bf7fd888 Mon Sep 17 00:00:00 2001 From: ch0c0l8ra1n <073bct532.rajat@pcampus.edu.np> Date: Sun, 21 Apr 2024 23:28:45 +0545 Subject: [PATCH 2/5] Bind shiny after opening pending swal --- inst/assets/lib/swalservice/swalservice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/assets/lib/swalservice/swalservice.js b/inst/assets/lib/swalservice/swalservice.js index 046e979..2f69594 100644 --- a/inst/assets/lib/swalservice/swalservice.js +++ b/inst/assets/lib/swalservice/swalservice.js @@ -78,6 +78,7 @@ SwalService.prototype = { if (service.pendingSwal.length > 0) { var pending = service.pendingSwal.shift(); service._swalWithId(pending); + Shiny.bindAll($(".sweet-alert")); } }, From 5060da7710d5170ead47377a16d738cd627767ee Mon Sep 17 00:00:00 2001 From: ch0c0l8ra1n <073bct532.rajat@pcampus.edu.np> Date: Tue, 23 Apr 2024 16:53:12 +0545 Subject: [PATCH 3/5] Now serving updated minified swalservice --- R/utils.R | 2 +- inst/assets/lib/swalservice/swalservice.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index 0bc4f83..4530f76 100644 --- a/R/utils.R +++ b/R/utils.R @@ -23,7 +23,7 @@ getDependencies <- function() { version = "1.0.0", package = "shinyalert", src = "assets/lib/swalservice", - script = "swalservice.js" + script = "swalservice.min.js" ), htmltools::htmlDependency( name = "shinyalert-binding", diff --git a/inst/assets/lib/swalservice/swalservice.min.js b/inst/assets/lib/swalservice/swalservice.min.js index 24eee3a..a56ec6d 100644 --- a/inst/assets/lib/swalservice/swalservice.min.js +++ b/inst/assets/lib/swalservice/swalservice.min.js @@ -1 +1 @@ -var SwalService=function(s){this.pendingSwal=[],s&&null!=s.showPendingMessage&&(this.showPendingMessage=s.showPendingMessage),this.initialize()};SwalService.prototype={currentSwal:null,showPendingMessage:!0,swalFirstCalled:!1,__swal:swal,pendingSwal:null,nextId:1,swal:function(){var s={args:arguments,id:this.nextId++};return this._swalWithId(s)},_swalWithId:function(s){return this.isSwalOpen()||this.isClosing?this.pendingSwal.push(s):(this.__swal.apply(null,s.args),this.currentSwal=s,this.swalFirstCalled||($(".sweet-alert").prepend(''),this.swalFirstCalled=!0)),this.refreshPendingText(),s.id},onClosed:function(){this.isClosing=!1,this.openNextSwal()},refreshPendingText:function(){this.showPendingMessage&&(0===this.pendingSwal.length?$(".other-messages").text(""):$(".other-messages").text(this.pendingSwal.length+" unread alerts"))},close:function(s){if(void 0===s||this.currentSwal&&this.currentSwal.id==s)this.__swal.close();else if(void 0!==s&&this.pendingSwal.length>0){for(var e,i=0;i0){var s=this.pendingSwal.shift();this._swalWithId(s)}},isSwalOpen:function(){return null!=this.currentSwal&&null!=this.currentSwal},closeAndFireCallback:function(s,e){var i=this.currentSwal;(this.close(s),i&&i.args&&i.args.length>1&&"function"==typeof i.args[1])&&(0,i.args[1])(e)},initialize:function(){var s=this,e=this.__swal.close;this.__swal.close=function(){s.isClosing=!0,e(),s.currentSwal=null,setTimeout(function(){s.onClosed()},400)}}}; +var SwalService=function(s){this.pendingSwal=[],s&&null!=s.showPendingMessage&&(this.showPendingMessage=s.showPendingMessage),this.initialize()};SwalService.prototype={currentSwal:null,showPendingMessage:!0,swalFirstCalled:!1,__swal:swal,pendingSwal:null,nextId:1,swal:function(){var s={args:arguments,id:this.nextId++};return this._swalWithId(s)},_swalWithId:function(s){return this.isSwalOpen()||this.isClosing?this.pendingSwal.push(s):(this.__swal.apply(null,s.args),this.currentSwal=s,this.swalFirstCalled||($(".sweet-alert").prepend(''),this.swalFirstCalled=!0)),this.refreshPendingText(),s.id},onClosed:function(){this.isClosing=!1,this.openNextSwal()},refreshPendingText:function(){this.showPendingMessage&&(0===this.pendingSwal.length?$(".other-messages").text(""):$(".other-messages").text(this.pendingSwal.length+" unread alerts"))},close:function(s){if(void 0===s||this.currentSwal&&this.currentSwal.id==s)this.__swal.close();else if(void 0!==s&&this.pendingSwal.length>0){for(var e,n=0;n0){var e=s.pendingSwal.shift();s._swalWithId(e),Shiny.bindAll($(".sweet-alert"))}},isSwalOpen:function(){return null!=this.currentSwal&&null!=this.currentSwal},closeAndFireCallback:function(s,e){var n=this.currentSwal;(this.close(s),n&&n.args&&n.args.length>1&&"function"==typeof n.args[1])&&(0,n.args[1])(e)},initialize:function(){var s=this,e=this.__swal.close;this.__swal.close=function(){s.isClosing=!0,e(),s.currentSwal=null,setTimeout((function(){s.onClosed()}),400)}}}; From 8edad2fdcc88f130762c3b902ab78026e58bca0f Mon Sep 17 00:00:00 2001 From: ch0c0l8ra1n <073bct532.rajat@pcampus.edu.np> Date: Tue, 23 Apr 2024 16:58:01 +0545 Subject: [PATCH 4/5] Added news entry --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 2e891a7..6d82e3f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ - Use `htmlDependency()` instead of `addResourcePath()` which is more robust and works in Rmd naturally (#71) - Don't show warning in R 4.2.0 when `text` is a list (#68) +- Fixed problem with queued shinyalerts not binding properly (#48 and #46) # shinyalert 3.0.0 (2021-12-20) From 9c0c59ba683903ee34807adace401b128ddb2797 Mon Sep 17 00:00:00 2001 From: Dean Attali Date: Tue, 23 Apr 2024 11:07:36 -0400 Subject: [PATCH 5/5] Update NEWS.md --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 6d82e3f..c114fc7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,8 @@ # Unreleased version +- Fixed bug where Shiny inputs and outputs did not work correctly when shinyalerts were chained together (#48 and #46) - Use `htmlDependency()` instead of `addResourcePath()` which is more robust and works in Rmd naturally (#71) - Don't show warning in R 4.2.0 when `text` is a list (#68) -- Fixed problem with queued shinyalerts not binding properly (#48 and #46) # shinyalert 3.0.0 (2021-12-20)