rhandsontable icon indicating copy to clipboard operation
rhandsontable copied to clipboard

Pasting data that would add columns to handsontable fails

Open s-fleck opened this issue 6 years ago • 8 comments

Pasting data into a handsontable so that the pasting adds new columns seems broken. I am using the latest version 0.3.6.1, but I also had the problem in older versions.

How to reproduce:

Create a handsontable like this:

  rhandsontable(
    iris,
    readOnly = FALSE,
    useTypes = FALSE,
    colHeaders = NULL
)

Select several columns, copy and paste them into the rightmost column.

I am using this in a shiny app, where I end up with the following error: Error in genColHeaders(changes, colHeaders): Change no recognized:afterChange. If I launch rhandsontable from the console with the code above, i just get wonky pasting behaviour.

edit: I forgott to mention that the error occurs when I call hot_to_r() on the rhandsontable object, not before.

s-fleck avatar Aug 07 '18 19:08 s-fleck

I'm not able to reproduce this issue with the latest version of the library. If I create a new rhandsontable using the code about, I can right-click, choose add a column on the left/right and then paste in data.

If you are still running into the issue, could you please include a complete example?

jrowen avatar Jan 21 '19 23:01 jrowen

It occurs only when several new columns would be added to the table due to pasting:

rhandsontable(
  iris,
  readOnly = FALSE,
  useTypes = FALSE,
  colHeaders = NULL
)
  1. run the code example above
  2. select a few rows from the first 4 columns, ctrl+c copy
  3. put the curser in the rightmost column (species)
  4. ctrl+v paste

expected behaviour

A few rows in the species column are overwritten with the pasted data, and 3 new columns are added to the table, containing the copied data.

what actually happens

a single empty column gets added to the table

Can you reproduce this? In the shiny app i am developing it also leads to a broken content for hot_to_r(). I will try to put together also a reprex for that, but give me one or two weeks please.

s-fleck avatar Jan 22 '19 07:01 s-fleck

Here is a reproducible shiny app example. Just try the procedure outlined above and the app will crash with Warning: Error in genColHeaders: Change no recognized:afterChange

library(rhandsontable)
library(shiny)

shinyApp(
  ui = fluidPage(
    shiny::mainPanel(
      rHandsontableOutput("hot")
    )
  ),
  
  server = function(input, output, session){
    output$hot <- renderRHandsontable(rhandsontable(iris[1:5, ], useTypes = FALSE))
    
    observeEvent(input$hot, {
      print(hot_to_r(input$hot))
    })
  }
)

without the observeEvent(...) it works as expected

s-fleck avatar Jan 26 '19 06:01 s-fleck

Having the same issue. @s-fleck did you manage to solve this?

elijah-woodstock avatar Aug 11 '19 17:08 elijah-woodstock

Nope no progress on this one :(

s-fleck avatar Aug 13 '19 19:08 s-fleck

having similar issue - with the same setup as above, simply inserting a column and typing some data in it, then calling hot_to_r is enough to cause crash with same error message.

stevepowell99 avatar Aug 14 '20 09:08 stevepowell99

Just wanted to share that I encountered the same error message too.

In my case, the problem was that my table has a column where each element is a list of strings. I had to flatten those lists and convert them into one string in order for hot_to_r() to not throw the error.

hsm207 avatar Sep 29 '20 04:09 hsm207

I also ran into this error.

In my case, the problem was a column that only had NULL values. Changing NULL to empty strings solved the problem.

PaulWestenthanner avatar Jun 12 '21 19:06 PaulWestenthanner