Odd behaviour of colored cells in rhandsontable when content is changed

33 Views Asked by At

In my rhandsontable, I need to render distinct cells with color. Now after the table is rendered, if I want to manually change the value in one of the colored cells, the original content remains visible, which is a disturbing user experience imho. E.g. if the original content is "Banana" and the user clicks into the cells and starts to delete the last 3 letters with backspace the word remains greyed out looking something like that: "Banana".

Screenshot:

https://i.stack.imgur.com/jbNze.png

Any ideas how to avoid this behaviour?

set.seed(42)  
n <- 6
dat <- data.frame(id=1:n, 
                  date=seq.Date(as.Date("2020-12-26"), as.Date("2020-12-31"), "day"),
                  group=rep(LETTERS[1:2], n/2),
                  age=sample(18:30, n, replace=TRUE),
                  type=factor(paste("type", 1:n)),
                  x=rnorm(n))

rhandsontable(
  dat,
  rowHeaders = NULL,
  row_highlight = 1:3,
) %>%
  hot_col(1, renderer = "
            function (instance, td, row, col, prop, value, cellProperties) {
                     Handsontable.renderers.TextRenderer.apply(this, arguments);

                     if (instance.params) {
                       hrows = instance.params.row_highlight
                       hrows = hrows instanceof Array ? hrows : [hrows]

                       if (hrows.includes(row)) { 
                         td.style.backgroundColor = 'rgba(3, 227, 77, 0.2)' 
                       }

                     }
            }")

I searched on several forums and read the documentation but either nothing addressing this issue exists or I overlooked.

0

There are 0 best solutions below