-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I have a shiny app where I use shinychat as a frontend for a RAG system. As I want to display sources to the users with nice UX, I would create button links that set some JS value using Shiny.setInputValue()
, which is picked up and the appropriate source is rendered elsewhere.
The problem is that somehow somewhere shinychat swallows the onclick element:
library(shiny)
# create sample content
sample_content <- span(
"This is the sample source content.",
tags$button(
class = "btn btn-sm btn-link",
onclick = "Shiny.setInputValue('from_js', {p: 1, v: Math.random()})",
"Sample from Page 1"
)
)
ui <- bslib::page_fillable(
bslib::layout_columns(
bslib::card(
bslib::card_header("Here it is rendered with onclick => works"),
sample_content
),
bslib::card(
bslib::card_header("Here it is rendered with shinychat::chat_append => does not work, no onlclick!"),
shinychat::chat_ui("out")
)
)
)
server <- function(input, output, session) {
shinychat::chat_append(
"out",
sample_content,
session = session
)
# see if there are any inputs sent from the UI
shiny::observe({
print("From JS:")
print(input$from_js)
cat("===========\n")
})
}
shinyApp(ui, server)
When I click on the "raw HTML" button (left side), I see something like this:
[1] "From JS:"
$p
[1] 1
$v
[1] 0.3141059
===========
[1] "From JS:"
$p
[1] 1
$v
[1] 0.6320509
when I click on the shinychat renderd button (right side) nothing is shown, when I inspect the button, I see this HTML source code without the onclick functionality
<button class="btn btn-sm btn-link">Sample from Page 1</button>
is there any way for me as a user to change this behavior or is there another workaround to setting some values from the output of the chat system?
Metadata
Metadata
Assignees
Labels
No labels