diff --git a/DESCRIPTION b/DESCRIPTION index 92a3bf78..6647b9e9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: DT Type: Package Title: A Wrapper of the JavaScript Library 'DataTables' -Version: 0.29.1 +Version: 0.29.2 Authors@R: c( person("Yihui", "Xie", email = "xie@yihui.name", role = c("aut", "cre")), person("Joe", "Cheng", role = "aut"), diff --git a/NEWS.md b/NEWS.md index d4632ccb..a8fcd20b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # CHANGES IN DT VERSION 0.30 +- Fixed a bug that when using `updateSearch()`, the clear button inside the input box doesn't show up, and the table doesn't update when the input is cleared (thanks, @DavidBlairs, #1082). # CHANGES IN DT VERSION 0.29 diff --git a/inst/htmlwidgets/datatables.js b/inst/htmlwidgets/datatables.js index b930851b..d968d8be 100644 --- a/inst/htmlwidgets/datatables.js +++ b/inst/htmlwidgets/datatables.js @@ -493,7 +493,9 @@ HTMLWidgets.widget({ $input.parent().hide(); $x.show().trigger('show'); filter[0].selectize.focus(); }, input: function() { - if ($input.val() === '') filter[0].selectize.setValue([]); + var v1 = JSON.stringify(filter[0].selectize.getValue()), v2 = $input.val(); + if (v1 === '[]') v1 = ''; + if (v1 !== v2) filter[0].selectize.setValue(v2 === '' ? [] : JSON.parse(v2)); } }); var $input2 = $x.children('select'); @@ -1398,7 +1400,7 @@ HTMLWidgets.widget({ console.log('The search keyword for column ' + i + ' is undefined') return; } - $(td).find('input').first().val(v); + $(td).find('input').first().val(v).trigger('input'); searchColumn(i, v); }); table.draw();