Skip to content

Conversation

@karangattu
Copy link

@karangattu karangattu commented Oct 22, 2024

What is this PR about?

Add viewport height & width along with scrollable area height and width to the clientdata.

DEMO

demo_resize

Example App

library(shiny)
library(bslib)

ui <- bootstrapPage(
  h3("URL components"),
  verbatimTextOutput("urlText"),

  h3("Parsed query string"),
  verbatimTextOutput("queryText")
)

server <- function(input, output, session) {

  # Return the components of the URL in a string:
  output$urlText <- renderText({
    paste(sep = "",
          "protocol: ", session$clientData$url_protocol, "\n",
          "hostname: ", session$clientData$url_hostname, "\n",
          "pathname: ", session$clientData$url_pathname, "\n",
          "port: ",     session$clientData$url_port,     "\n",
          "search: ",   session$clientData$url_search,   "\n",
          "width: ",    session$clientData$window_width, "\n",
          "height: ",   session$clientData$window_height, "\n",
          "scroll_width: ",  session$clientData$scroll_width, "\n",
          "scroll_height: ", session$clientData$scroll_height, "\n"
    )
  })

  # Parse the GET query string
  output$queryText <- renderText({
    query <- parseQueryString(session$clientData$url_search)

    # Return a string with key-value pairs
    paste(names(query), query, sep = "=", collapse=", ")
  })
}

shinyApp(ui, server)

Testing done

Verified that the values in clientdata are updated anytime the browser is resized. Tested it on Chrome, Firefox and Safari browsers on MacOS.

Documentation added

  • Added entry in NEWS.md file
  • Make changes in the website with this PR
@karangattu karangattu requested a review from wch October 22, 2024 19:58
@karangattu karangattu requested a review from cpsievert October 31, 2024 17:26
@gadenbuie gadenbuie added this to the Next Release milestone Nov 13, 2024
@gadenbuie gadenbuie modified the milestones: v1.10.0, Next Release Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants