diff --git a/inst/www/shared/shiny.js b/inst/www/shared/shiny.js index f02c7cabf..bec8879bf 100644 --- a/inst/www/shared/shiny.js +++ b/inst/www/shared/shiny.js @@ -5376,7 +5376,14 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope $(el).trigger('change'); }, subscribe: function subscribe(el, callback) { + var thiz = this; $(el).on('change.selectInputBinding', function (event) { + // https://github.com/rstudio/shiny/issues/2162 + // Prevent spurious events that are gonna be squelched in + // a second anyway by the onItemRemove down below + if (el.nonempty && thiz.getValue(el) === "") { + return; + } callback(); }); }, @@ -5401,6 +5408,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope }, JSON.parse(config.html())); // selectize created from selectInput() if (typeof config.data('nonempty') !== 'undefined') { + el.nonempty = true; options = $.extend(options, { onItemRemove: function onItemRemove(value) { if (this.getValue() === "") $("select#" + $escape(el.id)).empty().append($("