-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix both bugs in #31 #32
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Demo exampleslibrary(shiny)
library(shinyalert)
ui <- fluidPage(
shinyalert::useShinyalert(),
actionButton('a','Timer works when multiple alerts are queued'),
actionButton('b','Immediate = TRUE'),
actionButton('c','callbackR close alerts automatically'),
actionButton('d','3 alerts, but the third alert only closes the first one'),
actionButton('e','3 alerts, once the first one closes, the second alert closes too'),
actionButton('f','Alert within callbackR')
)
server <- function(input, output, session) {
# ----- Timer works when multiple alerts are queued ------
observeEvent(input$a, {
shinyalert::shinyalert(
'This alert close automatically',
'Wait...',
timer = 3000,
showConfirmButton = FALSE
)
shinyalert::shinyalert(
'Yay',
' '
)
})
# ----- Immediate = TRUE ------
observeEvent(input$b, {
shinyalert::shinyalert(
'Test the following case',
'<pre>Immediate = TRUE</pre>',
closeOnClickOutside = FALSE,
showConfirmButton = FALSE,
html = TRUE
)
Sys.sleep(2)
shinyalert::shinyalert(
'Auto close the first one!',
'', timer = 3000, immediate = TRUE
)
})
# ----- callbackR close alerts automatically ------
observeEvent(input$c, {
shinyalert::shinyalert(
'Warning',
'Click OK to run code',closeOnClickOutside = TRUE,
callbackR = function(...){
# procedure 1 runs for 3~4 seconds
Sys.sleep(3 + runif(1))
# Now dismiss modal
shinyalert::closeAlert(2)
}
)
shinyalert::shinyalert(
'Scheduled!',
'R is running, please wait for the result...',
showConfirmButton = FALSE
)
})
# ----- 3 alerts, but the third alert only closes the first one -----
shiny::observeEvent(input$d, {
cbid_a <- shinyalert::shinyalert(
'This is alert A',
'It automatically closes once C is queued',
showConfirmButton = FALSE
)
shinyalert::shinyalert(
'This is alert B',
'C only closes A but not B',
callbackR = function(...){
Sys.sleep(3)
shinyalert::closeAlert()
}
)
Sys.sleep(2)
shinyalert::shinyalert(
'This is alert C',
'Wait for callback (B) to finish',
showConfirmButton = FALSE
)
shinyalert::closeAlert(cbid = cbid_a)
})
# ----- 3 alerts, once the first one closes, the second alert closes too -----
shiny::observeEvent(input$e, {
shinyalert::shinyalert(
'This is alert A',
'Close A will also close B',
callbackR = function(...){
# close one alert, which is B
closeAlert(n = 1)
}
)
shinyalert::shinyalert(
'This is alert B',
'You might be unable to see me'
)
shinyalert::shinyalert(
'This is alert C',
'A, B are closed, only me left'
)
})
# ----- Alert within callbackR -----
observeEvent(input$f, {
shinyalert::shinyalert(
"modal 1",
timer = 1000,
callbackR = function() {
shinyalert::shinyalert("modal 2")
})
})
}
shinyApp(ui, server)
|
These two JS bugs can be fixed independently of the closeAlert PR, right? This PR should only contain the code to fix those two js issues, nothing else :) |
Merged in #37 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #31 and #29
Commit e8c393d added closeAlert and immediate requested by #29 and #30. It automatically fixes bug2 in #31
Commit 66b430e fixed two js bugs and allows closeAlert to close a specific alert
Commit 839117e fixes all bugs in #31