Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiny and Colreorder, doesn't sort columns properly after drag and drop #921

Closed
3 tasks done
nmoraesmunter opened this issue Jul 9, 2021 · 4 comments · Fixed by #1096
Closed
3 tasks done

Shiny and Colreorder, doesn't sort columns properly after drag and drop #921

nmoraesmunter opened this issue Jul 9, 2021 · 4 comments · Fixed by #1096

Comments

@nmoraesmunter
Copy link

nmoraesmunter commented Jul 9, 2021

Minimal code to reproduce the issue (shiny v1.6.0 DT v0.18)

library(shiny)
library(DT)

ui <- fluidPage(
  br(),
  DTOutput("tbl"),
  br()
)

server <- function(input, output, session){
  
  output$tbl <- renderDT({
    datatable(mtcars, extensions = "ColReorder", 
              options = list(colReorder = TRUE)
    )
  })
  
}

shinyApp(ui, server)
  1. Click in a column header (for example qsec). Check that it's sorted correctly. (ascendent order of qsec values 14.5, 14.6, 15.41, 15.5...)
  2. Drag the column to another position ( I put it one column to the left, between drat and wt)
  3. Click in the column header of the dragged column. Check that it's not sorting that column properly (ascendent order of qsec values 16.9, 18.52, 19.9, 18.9, 16.7..)

It seems to me that it looses the right indexing when dragging and dropping and it is ordering by another column. I have tried to run it without Shiny and it works as expected, that's why I think that the issue is when interacting with Shiny.

datatable(mtcars, extensions = "ColReorder", 
              options = list(colReorder = TRUE)
    )

Posted in Stackoverflow https://stackoverflow.com/questions/68302326/shiny-and-colreorder-doesnt-sort-properly-after-column-after-drag-and-drop


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/DT').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@nmoraesmunter
Copy link
Author

I deployed the minimal code into https://nmuenter.shinyapps.io/colreorder/ where the issue can be reproduced

@nmoraesmunter
Copy link
Author

I just noticed that issue only happens with server = TRUE.

@nmoraesmunter
Copy link
Author

I believe it's related to what is mentioned here:

#534

@yihui
Copy link
Member

yihui commented Nov 16, 2023

It's finally fixed... You can test the development version via

remotes::install_github('rstudio/DT')

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants