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

Fix phantom change event when initial HOT has 0 rows #373

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rhandsontable
Type: Package
Title: Interface to the 'Handsontable.js' Library
Version: 0.3.707
Version: 0.3.799
Authors@R: c(
person("Jonathan", "Owen", email = "[email protected]",
role = c("aut", "cre", "cph")),
Expand Down Expand Up @@ -43,5 +43,6 @@ Suggests:
rstudioapi (>= 0.6),
htmltools
VignetteBuilder: knitr
RoxygenNote: 7.0.2
RoxygenNote: 7.1.1
Encoding: UTF-8
Repository: SPDGT
2 changes: 1 addition & 1 deletion R/rhandsontable.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ rhandsontable <- function(data, colHeaders, rowHeaders, comments = NULL,
res = list(type = type)
}
res$readOnly = readOnly
res$renderer = JS("customRenderer")
res$renderer = htmlwidgets::JS("customRenderer")
res$default = NA
res
})
Expand Down
8 changes: 6 additions & 2 deletions inst/htmlwidgets/rhandsontable.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ HTMLWidgets.widget({
}

if (HTMLWidgets.shinyMode) {
if (changes && (changes[0][2] !== null || changes[0][3] !== null)) {
if (changes && (changes[0][2] != null || changes[0][3] != null)) {
if (this.sortIndex && this.sortIndex.length !== 0) {
c = [this.sortIndex[changes[0][0]][0], changes[0].slice(1, 1 + 3)];
} else {
Expand Down Expand Up @@ -242,7 +242,11 @@ HTMLWidgets.widget({

if (this.params && this.params.columns) {
for(var i = 0, colCount = this.countCols(); i < colCount ; i++) {
this.setDataAtCell(ind, i, this.params.columns[i].default);
// added to prevent phantom change event - change will still fire
// if default values are provided
if (this.params.columns[1].default !== null) {
this.setDataAtCell(ind, i, this.params.columns[i].default);
}
}
}

Expand Down