jrowen/rhandsontable

renderRHandsontable does not render table correctly if it takes too long to execute (about 1 second)

KallyopeBio opened this issue · 0 comments

I have an extremely simple reproducible example, attached.
rhandsontable_reprex.txt

To see the problem:
1.) Run the app
2.) Change the text in (row 1, col 1) from "Row1" to anything else. Your change will be converted to the string "Input overwritten". This is the desired behavior.
3.) Now change the text in (row 2, col 1) from "Row2" to anything else. You'll see the actual text you entered, not the modified version which should be rendered (i.e., "This should also be overwritten, but it is not"). This is undesired behavior, caused by adding a relatively slow computation to the code block that processes inputs to the second row of the table.

The broader context:
In a Shiny app, I have an rhandsontable. When the user modifies certain fields, I may want to transform the user's input, and have that transformed result appear immediately in the table, not the text the user actually entered. (The use case involves automatically correcting errors in user input.)

So in renderRHandsontable(), I may modify the data frame returned by hot_to_r(), and then pass that modified data frame to rhandsontable().

All of this works exactly as I'd expect, unless the renderRHandsontable() function needs to perform some expensive calculation (that runs on the order of 1 second), in which case the rendered table displays the user's original input and not the auto-transformed version.

In the attached file, on line 24, if you change "dummy <- rnorm(1e7)" (which is 'slow') to "dummy <- rnorm(1e1)" (which is 'fast'), then the table correctly displays the modified text and the bug disappears.

Is there some other recommended way of automatically modifying/tweaking inputs to the rhandsontable?

Regards,
Justin