You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating the items argument of a shinyjqui::orderInput widget via updateOrderInput, unexpected results occur when the updated items is a named vector or named list.
The following message is printed in console: Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
Only the first vector/list item is shown in the widget on the browser.
The value returned by input$inputID = "[object Object]" (screenshot taken from app example below)
Minimal example:
library(shiny)
library(shinyjqui)
## Uncomment the one you want to use#toUpdate <- month.abb[1:6] # Normal vector works fine#toUpdate <- stats::setNames(1:6, nm = month.abb[1:6]) # Named vector does not work#toUpdate <- as.list(stats::setNames(1:6, nm = month.abb[1:6])) # Named list does not work#toUpdate <- factor(month.abb[1:6]) # Factor works.ui<- fluidPage(
orderInput("foo", "label",
items=NULL,
item_class='default'),
verbatimTextOutput("order"),
actionButton("update", "update")
)
server<-function(input, output, session) {
output$order<- renderPrint({input$foo})
observeEvent(input$update, {
updateOrderInput(
session, "foo",
items=toUpdate
)
})
}
shinyApp(ui, server)
The specifying a named vector or list in orderInput seems to be no problem.
Bug description
When updating the
items
argument of ashinyjqui::orderInput
widget viaupdateOrderInput
, unexpected results occur when the updated items is a named vector or named list.Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
input$inputID
="[object Object]"
(screenshot taken from app example below)Minimal example:
The specifying a named vector or list in
orderInput
seems to be no problem.The text was updated successfully, but these errors were encountered: