-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
It would be a great addition to have a function that let's the shiny server update the textarea input.
We have a small library of prompts that we display to the user, when the user selects one, we want to fill the input with this text.
An MWE looks like this
ui <- bslib::page_fillable(
shiny::tags$script(shiny::HTML("
Shiny.addCustomMessageHandler('setTextArea', function(msg) {
console.log(msg);
document.getElementById(msg.id).textarea.value = msg.text;
});
")),
shinychat::chat_ui("mychat"),
shiny::actionButton("btn_set_value", "Use Prompt 'hello world'")
)
server <- function(input, output, session) {
shiny::observeEvent(input$btn_set_value, {
session$sendCustomMessage(
"setTextArea",
list(id = session$ns("mychat_user_input"),
text = "Hello World")
)
})
}
shiny::shinyApp(ui, server)This works but is not as easy to use for all users than a shinychat::update_user_input() or so.
Metadata
Metadata
Assignees
Labels
No labels