as you know an item inside the selectizeinput can just be deleted by pressing "delete", but not by clicking on it. This reduces the user experience of my dashboards dramatically. Here is a solution which deletes ALL inputs in the input fields, however I only want to delete the one, which was clicked.
library(shiny)
library(dplyr)
library(shinyjs)
ui= fluidPage(
useShinyjs(),
sidebarLayout(
sidebarPanel(
selectizeInput(inputId= "cyl", label= "cyl",
choices= NULL,
selected= sort(unique(mtcars$cyl))[1],
multiple=T)
),
mainPanel(
tableOutput("tab")
)
)
)
server= function(input, output,session) {
updateSelectizeInput(session = session,inputId ="cyl",choices=sort(unique(mtcars$cyl)),selected=sort(unique(mtcars$cyl))[1], server = TRUE)
df_filtered= reactive({
mtcars %>%
{if (is.null(input$cyl)) . else filter(., cyl %in% input$cyl)}
})
output$tab= renderTable(df_filtered())
onclick("cyl", {
updateSelectizeInput(session, "cyl", selected = "")
})
}
shinyApp(ui, server)
Is there any option to to this? I thought about triggering a keydown event via javascript, but this did not work yet :-(. Can you guys help me?