insightsengineering / insightsengineering/teal.slice
[Bug]: Slices cannot be added
- Dominant language
- R
- Stars
- 12
- Forks
- 7
- Avg merge
- 3d 31m
- Merged PRs (30d)
- 1
Description
### What happened?
Sometimes it is not possible to add filters: The app opens but doesn't have the buttons to modify/add filters:
App
```r
library("teal.slice")
library("shiny")
datasets <- init_filtered_data(list(iris = iris, mtcars = mtcars))
ui <- fluidPage(
fluidRow(
column(
width = 9,
tabsetPanel(
tabPanel(title = "iris", DT::DTOutput("iris_table")),
tabPanel(title = "mtcars", DT::DTOutput("mtcars_table"))
)
),
# ui for the filter panel
column(
width = 3,
# What we want to test:
datasets$ui_filter_panel("filter_panel")
)
)
)
server <- function(input, output, session) {
# this is the shiny server function for the filter panel and the datasets
# object can now be used inside the application
datasets$srv_filter_panel("filter_panel")
# get the filtered datasets and put them inside reactives for analysis
iris_filtered_data <- reactive(datasets$get_data(dataname = "iris", filtered = TRUE))
mtcars_filtered_data <- reactive(datasets$get_data(dataname = "mtcars", filtered = TRUE))
output$iris_table <- DT::renderDataTable(iris_filtered_data())
output$mtcars_table <- DT::renderDataTable(mtcars_filtered_data())
}
app <- shinyApp(ui, server)
runApp(app)
```
If there isn't one set using `set_filter_state(filter = teal_slices( ))` with at least one `teal_slice()` the button show up.
With teal applications it is possible to add filters:
Details
```r
library(teal)
app <- init(
data = teal_data(iris = iris),
modules = list(
module(
label = "iris histogram",
server = function(input, output, session, data) {
updateSelectInput(session = session,
inputId = "var",
choices = names(data()[["iris"]])[1:4])
output$hist <- renderPlot({
req(input$var)
hist(x = data()[["iris"]][[input$var]])
})
},
ui = function(id) {
ns <- NS(id)
list(
selectInput(inputId = ns("var"),
label = "Column name",
choices = NULL),
plotOutput(outputId = ns("hist"))
)
}
)
)
)
shinyApp(app$ui, app$server)
```
Found while testing for #653
### sessionInfo()
```R
```
### Relevant log output
```R
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct.
### Contribution Guidelines
- [x] I agree to follow this project's Contribution Guidelines.
### Security Policy
- [x] I agree to follow this project's Security Policy.
Contributor guide
Assessment
This issue has not been assessed yet.