rstudio/sortable

Multi-drag is not working

jianhaizhang opened this issue · 7 comments

Multi-drag is not working

The following code is an example from this package. Why the mult-drag and swap behavior is not working?

library(shiny); library(sortable)
labels <- list(
  "one",
  "two",
  "three",
  htmltools::tags$div(
    htmltools::em("Complex"), " html tag without a name"
  ),
  "five" = htmltools::tags$div(
    htmltools::em("Complex"), " html tag with name: 'five'"
  )
)

rank_list_basic <- rank_list(
  text = "Drag the items in any desired order",
  labels = labels,
  input_id = "rank_list_basic"
)

rank_list_swap <- rank_list(
  text = "Notice that dragging causes items to swap",
  labels = labels,
  input_id = "rank_list_swap",
  options = sortable_options(swap = TRUE)
)

rank_list_multi <- rank_list(
  text = "You can select multiple items, then drag as a group",
  labels = labels,
  input_id = "rank_list_multi",
  options = sortable_options(multiDrag = TRUE)
)



ui <- fluidPage(
  fluidRow(
    column(
      width = 12,
    tags$h2("Default, multi-drag and swapping behaviour"),
      tabsetPanel(
        type = "tabs",
        tabPanel(
          "Default",
            tags$b("Exercise"),
            rank_list_basic,
            tags$b("Result"),
            verbatimTextOutput("results_basic")
        ),
        tabPanel(
          "Multi-drag",
            tags$b("Exercise"),
            rank_list_multi,
            tags$b("Result"),
            verbatimTextOutput("results_multi")
        ),
        tabPanel(
          "Swap",
            tags$b("Exercise"),
            rank_list_swap,
            tags$b("Result"),
            verbatimTextOutput("results_swap")
        )
      )
    )
  )
)

server <- function(input, output) {
  output$results_basic <- renderPrint({
    input$rank_list_basic # This matches the input_id of the rank list
  })
  output$results_multi <- renderPrint({
    input$rank_list_multi # This matches the input_id of the rank list
  })
  output$results_swap <- renderPrint({
    input$rank_list_swap # This matches the input_id of the rank list
  })
}

shinyApp(ui, server)

What behaviour do you see? When I run this code everything seems to be working as expected. The "multi-drag" tab allows you to select multiple elements and drag them together, and the "swap" tab swaps items, rather than inserting.

Please provide the results of sessioninfo::session_info()

Hello,

Thanks for your reply.

Now the multi-drag feature is working, but only one item rather than all selected is highlighted. In the "swap" feature, it works the same way with "basic", items not swapped.

sessioninfo::session_info()                                                                                              [16/236]
─ Session info ───────────────────────────────────────────────────────────────                                                    
 setting  value
 version  R version 4.0.0 (2020-04-24)
 os       Ubuntu 16.04.5 LTS
 system   x86_64, linux-gnu
 ui       X11
 language en_US:en_GB:en
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Los_Angeles
 date     2020-08-03

─ Packages ───────────────────────────────────────────────────────────────────                                                    
 package     * version date       lib source
 assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.0)
 backports     1.1.7   2020-05-13 [1] CRAN (R 4.0.0)
 cli           2.0.2   2020-02-28 [1] CRAN (R 4.0.0)
 crayon        1.3.4   2017-09-16 [1] CRAN (R 4.0.0)
 digest        0.6.25  2020-02-23 [1] CRAN (R 4.0.0)
 evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.0)
 fansi         0.4.1   2020-01-08 [1] CRAN (R 4.0.0)
 fastmap       1.0.1   2019-10-08 [1] CRAN (R 4.0.0)
 glue          1.4.1   2020-05-13 [1] CRAN (R 4.0.0)
 htmltools     0.4.0   2019-10-04 [1] CRAN (R 4.0.0)
 htmlwidgets   1.5.1   2019-10-08 [1] CRAN (R 4.0.0)
 httpuv        1.5.2   2019-09-11 [1] CRAN (R 4.0.0)
 jsonlite      1.6.1   2020-02-02 [1] CRAN (R 4.0.0)
 knitr         1.28    2020-02-06 [1] CRAN (R 4.0.0)
 later         1.0.0   2019-10-04 [1] CRAN (R 4.0.0)
 learnr        0.10.1  2020-02-13 [1] CRAN (R 4.0.0)
 magrittr      1.5     2014-11-22 [1] CRAN (R 4.0.0)
 markdown      1.1     2019-08-07 [1] CRAN (R 4.0.0)
 mime          0.9     2020-02-04 [1] CRAN (R 4.0.0)
 promises      1.1.0   2019-10-04 [1] CRAN (R 4.0.0)
 R6            2.4.1   2019-11-12 [1] CRAN (R 4.0.0)
 Rcpp          1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0)
 rlang         0.4.6   2020-05-02 [1] CRAN (R 4.0.0)
 rmarkdown     2.1     2020-01-20 [1] CRAN (R 4.0.0)
 rprojroot     1.3-2   2018-01-03 [1] CRAN (R 4.0.0)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.0)
 shiny       * 1.4.0.2 2020-03-13 [1] CRAN (R 4.0.0)
 sortable    * 0.4.2   2019-12-01 [1] CRAN (R 4.0.0)
 withr         2.2.0   2020-04-20 [1] CRAN (R 4.0.0)
 xfun          0.13    2020-04-13 [1] CRAN (R 4.0.0)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 4.0.0)
 yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.0)

[1] /usr/local/lib/R/site-library
[2] /usr/lib/R/site-library
[3] /usr/lib/R/library

Please try again using the dev version.

Working well now. Thanks!

Please try again using the dev version.

Hi @andrie , will the dev version be released in the coming Bioconductor release?

I'm sorry, but I don't understand your question. The sortable package (including this fix) has been on CRAN for some time. I don't know whether BioConductor includes sortable or not.

As long as this fix was included on CRAN, that's fine. Thanks!