dash-core-components icon indicating copy to clipboard operation
dash-core-components copied to clipboard

dccLink or dcc Location encodes URL upon refresh

Open mjkallen opened this issue 5 years ago • 1 comments

I'm not sure if this is intended behavior, but dccLink("click me", href = "/foo?p=1", refresh = TRUE) will encode the ? in the URL upon refreshing. This will create an incorrect path name.

Here's a sample app to illustrate my problem:

library("dash")
library("dashCoreComponents")
library("dashHtmlComponents")

app <- Dash$new(suppress_callback_exceptions = TRUE)

app$layout(dccLocation(id = "url"), htmlDiv(id = "page-content"))

app$callback(
  output = list(id = "page-content", property = "children"),
  params = list(input(id = "url", property = "pathname")),
  function(path) {
    if (path == "/") {
      list(
        htmlP(dccLink("'/foo?p=1' with ddcLink and refresh=TRUE",
                      href = "/foo?p=1",
                      refresh = TRUE)),
        htmlP(dccLink("'/foo?p=1' with ddcLink and refresh=FALSE",
                      href = "/foo?p=1",
                      refresh = FALSE))
      )

    } else if (path == "/foo") {
      htmlP("It works!")

    } else {
      htmlP("Something went wrong!")

    }
  }
)

app$run_server(debug = TRUE)

Of course, the correct result can be achieved using htmlA and I realize that this may not actually be related to DashR itself, but to Dash in general.

mjkallen avatar Sep 20 '19 11:09 mjkallen

This might be browser / device dependent - We've had some reports where the query string generated from Apple devices is different than others. For Python users, we recommend using python's built in url parsing functionality (https://docs.python.org/3/library/urllib.parse.html). Not sure if there is an equivalent in R.

@mjkallen - Do you recall which browser you tested on? And by encode do you mean something like %5D?

chriddyp avatar Aug 28 '20 21:08 chriddyp