Comments (8)
I just found out that I have the same issue. This is currently a big show stopper for me, too. Have you ever found a way around this?
Here's a reproducible example I made by adapting the updateCollapse example (https://ebailey78.github.io/shinyBS/docs/Collapses.html#updateCollapse):
library(shiny)
library(shinyBS)
shinyApp(
ui = fluidPage(sidebarLayout(
sidebarPanel(
HTML("This button will open Panel 1 using updateCollapse."),
actionButton("p1Button", "Push Me!"),
selectInput("styleSelect", "Select style for Panel 1",
c("default", "primary", "danger", "warning", "info", "success"))
),
mainPanel(
bsCollapse(
id = "collapseExample", open = "Panel 2",
bsCollapsePanel(
title = "Panel 1",
style = "info",
p("This is a panel which has the default style. You can change the style in the sidebar."),
p("However, something goes wrong with this panel's shiny communication when there is a visible conditionalPanel inside of it. First, set", code("options(shiny.trace = TRUE)"), " and start the app. Open and close panels 1 and 2 and you'll see messages like this in the console:"),
p(code("RECV {'method':'update','data':{'collapseExample':['Panel 1'],'.clientdata_output_genericPlot_hidden':true}}")),
p(code("RECV {'method':'update','data':{'collapseExample':['Panel 2'],'.clientdata_output_genericPlot_hidden':false}}")),
p("Now choose the panel style 'danger' in the sidebar which will trigger the display of a conditionalPanel within panel 1. Then open and close panels 1 and 2 again and watch shiny's messages in the console:"),
p(code("RECV {'method':'update','data':{'collapseExample':['Panel 1','Panel 2'],'.clientdata_output_genericPlot_hidden':false}}")),
p(code("RECV {'method':'update','data':{'collapseExample':['Panel 1','Panel 1'],'.clientdata_output_genericPlot_hidden':true}}")),
conditionalPanel(
condition = "input.styleSelect == 'danger'",
wellPanel(
h1("DANGER ZONE"),
p("'Panel 1' seems to be added to shiny's messages. This can mess up everything pretty bad if one uses a lot of conditional panels.")
)
)
),
bsCollapsePanel(
title = "Panel 2",
style = "success",
"This panel has a generic plot. ",
"and a 'success' style.",
plotOutput("genericPlot")
)
)
)
)),
server = function(input, output, session) {
output$genericPlot <- renderPlot(plot(rnorm(100)))
observeEvent(input$p1Button, ({
updateCollapse(session, "collapseExample", open = c("Panel 1"))
}))
observeEvent(input$styleSelect, ({
updateCollapse(session, "collapseExample",
style = list("Panel 1" = input$styleSelect))
}))
}
)
from shinybs.
I did not find a workaround. I ended up not using this feature in my projects
from shinybs.
Damn it. Thanks anyway for the quick response!
from shinybs.
@pan0ramic Don't know whether you got notified automatically, but I just made a pull request with a fix for this issue. Hopefully, that is. Seems to work for my shiny app.
from shinybs.
+1 also having this issue.
from shinybs.
@mattflor I didn't see this! Thanks for making the commit. Doesn't look like the author wants to merge though :(
from shinybs.
We have encountered the same issue (nested collapsePanels or conditionPanels within a collapsePanel). It seems that the nested elements fire the same event (show.bs.collapse and hide.bs.collapse). The provided fix did not solve the issue in our case. However, adding an explicit check whether the parent().parent() of the event.target is the actual bsCollapsePanel (and thereby avoiding nested events) did it:
$panels.on("show.bs.collapse", function(event) {
// make sure this is not an event from a nested element
if(!($el.is($(event.target).parent().parent()))) {
return;
}
// ...
});
$panels.on("hide.bs.collapse", function(event) {
// make sure this is not an event from a nested element
if(!($el.is($(event.target).parent().parent()))) {
return;
}
// ...
});
Perhaps there is a more elegant solution...
from shinybs.
I also encountered this bug. I proposed a workaround on Stackoverflow (https://stackoverflow.com/questions/58015021/conflict-between-shinybsbscollapse-and-shinyconditionalpanel) where shiny::conditionalPanel is replaced by the following:
uiOutput("condPanelA")
output$condPanelA <- renderUI({
if(input$showPanelA) {
helpText("Panel A conditional content")
} else {
NULL
}
})
from shinybs.
Related Issues (20)
- Fast clicks can cause issues with bsModal
- Jquery error Uncaught Error: Syntax error, unrecognized expression: # HOT 2
- Mt app is frozen when close two opened modals
- FR: Allow updating additional attributes in `updatePanel`
- FR: Allow specification of id tag in bsCollapsePanel
- FR: Add 'multiple' parameter to `collapseUpdate`
- Uncaught referenceErrorL ShinyBS is not defined at ..... HOT 4
- Soft wrap long text in bsCollapsePanel()
- Is someone taking over support of this package?
- Change the way shinyBS adds resource path HOT 1
- modal is not working in ioslides_presentation
- Tooltips does not show up with shinyDashboard boxes sidebar
- bsModal works with shinydashboard but not when tabItems / tabItem are utilized HOT 2
- Dependencies failed to load HOT 1
- Alternatives to shinyBS HOT 1
- bsPopover (tooltip) not working in shinyapps.io
- feature request, load function HOT 1
- createAlert styles
- bsTooltip broken for selectizeInput and selectInput(..., multiple = T) HOT 1
- Lazy loading
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinybs.