quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
141 stars 7 forks source link

viewerHeight doesn't work when editor is used #44

Closed royfrancis closed 3 months ago

royfrancis commented 4 months ago

The height of viewer changes based on viewerHeight as expected.

Screenshot 2024-03-20 at 17 18 47

But when editor is displayed, the viewerHeight doesn't seem to have an effect.

Screenshot 2024-03-20 at 17 17 54

Here is the test code:

---
title: Index3
format:
  html
filters: 
  - shinylive
---

```{shinylive-r}
#| standalone: true
#| viewerHeight: 420
#| components: [editor, viewer]

shinyApp(
ui=fluidPage(
  selectInput("data_input",label="Select data",choices=c("mtcars","faithful","iris")),
  selectInput("header_input",label="Select column name",choices=NULL),
  plotOutput("plot_output",width="400px")
),

server=function(input,output,session) {
  getdata <- reactive({ get(input$data_input, 'package:datasets') })

  observe({
    updateSelectInput(session,"header_input",label="Select column name",choices=colnames(getdata()))
  })

  output$plot_output <- renderPlot({
    #shiny::req(input$header_input)
    #validate(need(input$header_input %in% colnames(getdata()),message="Incorrect column name."))
    hist(getdata()[, input$header_input],xlab=input$header_input,main=input$data_input)
  })
})
#| standalone: true
#| viewerHeight: 600
#| components: [editor, viewer]

shinyApp(
ui=fluidPage(
  selectInput("data_input",label="Select data",choices=c("mtcars","faithful","iris")),
  selectInput("header_input",label="Select column name",choices=NULL),
  plotOutput("plot_output",width="400px")
),

server=function(input,output,session) {
  getdata <- reactive({ get(input$data_input, 'package:datasets') })

  observe({
    updateSelectInput(session,"header_input",label="Select column name",choices=colnames(getdata()))
  })

  output$plot_output <- renderPlot({
    #shiny::req(input$header_input)
    #validate(need(input$header_input %in% colnames(getdata()),message="Incorrect column name."))
    hist(getdata()[, input$header_input],xlab=input$header_input,main=input$data_input)
  })
})

quarto 1.4.549 quarto-shinylive 0.1.0

royfrancis commented 3 months ago

To increase height, one option is to add empty lines in the text editor.

royfrancis commented 3 months ago

Same issue as #33