How to update with content containing multiple lines using updateTextAreaInput

I need to do

updateTextAreaInput(session = session,
inputId = contextID,
value = content)

where content has multiple lines.
Whether content is a string with'\n' inserted or a character vector with length > 1,
the textarea will show '\n' instead of newlines.

Any ideas, friends?

It actually shows new lines with '\n' for me. Tested on Firefox and Edge


ui <- fluidPage(
   titlePanel("Text Area update"),
         actionButton('btnUpdate', 'Update')
        textAreaInput(inputId = 'testInput', 'Test', value = '', height = '400px')

server <- function(input, output, session) {
  observeEvent(input$btnUpdate, {
    updateTextAreaInput(session = session,
                        inputId = 'testInput',
                        value = 'abcd\ncde')
shinyApp(ui = ui, server = server)
1 Like

Ha, the joke's on me,
I was reading the new text from a file with '\n' in strings,
and somehow ended up with '\\n' instead.
Thanks for your help!