Skip to content

parseDirPath provides wrong path if defaultPath and defaultRoot are set in shinyDirChoose #110

@lbusett

Description

@lbusett

Hi,

I am working with shinyDirButton and shinyDirChoose to allow selection of a folder, starting from a specific default folder specified throgh defaultPath and defaultRoot. The problem is that when I then invoke parseDirPath to get the selected folder name, apparently the defaultPath value is ignored.

In practice, the returned path is

 `defaultRoot/name_of_folder`

while if I get the expected functionality right, it should be:

 `defaultRoot/defaultPath/name_of_folder`

Below you can find an example (not really reprex because it is related to my "paths"):

library(shiny)
library(shinyFiles)

ui <- {
  volumes <- c(main = "/home/lb/")
  shinyUI(fluidPage(
  
  titlePanel("Example"),
  shinyDirButton("savedir", "Save folder", "Save folder")
  ))
}
server <- shinyServer(function(input, output, session) {
  
  shinyDirChoose(input, "savedir",
                 roots=volumes,
                 defaultPath = "tmp", 
                 defaultRoot = "main",
                 session=session)
  
  observeEvent(input$savedir, {
     dirinfo <- parseDirPath(volumes, input$savedir)
     print(dirinfo)
  })
})

shinyApp(ui = ui, server = server)

If I run the example, I correctly get a "list of folders" starting from my "/home/lb/tmp" (although I see "main" on the top instead than "tmp" or "main/tmp"):

image

However, if I now select the "buttami" subfolder and click on "select", the path returned by

dirinfo <- parseDirPath(volumes, input$savedir)

is "/home/lb/buttami", while I would expect it to be "/home/lb/tmp/buttami"

Am I missing something/misunderstanding the functionality, here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions