Skip to content

Commit

Permalink
Fix selectize event namespacing issues (#3919)
Browse files Browse the repository at this point in the history
Co-authored-by: cpsievert <[email protected]>
  • Loading branch information
cpsievert and cpsievert authored Oct 20, 2023
1 parent 7069064 commit ce78d0d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 34 deletions.
7 changes: 5 additions & 2 deletions inst/www/shared/selectize/js/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,18 @@ var Selectize = function($input, settings) {

self.settings = {};

// increase the count of 'active' (i.e., non-destroyed) selectize instances
++Selectize.count;

$.extend(self, {
order : 0,
settings : settings,
$input : $input,
tabIndex : $input.attr('tabindex') || '',
tagType : input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
rtl : /rtl/i.test(dir),

eventNS : '.selectize' + (++Selectize.count),
// generate a unique ID for the event namespace
eventNS : '.selectize-' + (new Date().getTime()) + '-' + (Math.random().toString(36).substr(2, 5)),
highlightedValue : null,
isBlurring : false,
isOpen : false,
Expand Down
33 changes: 1 addition & 32 deletions inst/www/shared/selectize/js/selectize.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions srcts/build/external_libs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ build({
minify: true,
});

build({
...opts,
entryPoints: [outDir + "selectize/js/selectize.js"],
outfile: outDir + "selectize/js/selectize.min.js",
minify: true,
target: "es6",
});

build({
...opts,
entryPoints: [outDir + "selectize/accessibility/js/selectize-plugin-a11y.js"],
Expand Down
25 changes: 25 additions & 0 deletions tools/selectize-patches/007-selectize-event-namespace-bugfix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/inst/www/shared/selectize/js/selectize.js b/inst/www/shared/selectize/js/selectize.js
index 0b447a7b3..cbfe9178e 100644
--- a/inst/www/shared/selectize/js/selectize.js
+++ b/inst/www/shared/selectize/js/selectize.js
@@ -834,6 +834,9 @@ var Selectize = function($input, settings) {

self.settings = {};

+ // increase the count of 'active' (i.e., non-destroyed) selectize instances
+ ++Selectize.count;
+
$.extend(self, {
order : 0,
settings : settings,
@@ -841,8 +844,8 @@ var Selectize = function($input, settings) {
tabIndex : $input.attr('tabindex') || '',
tagType : input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
rtl : /rtl/i.test(dir),
-
- eventNS : '.selectize' + (++Selectize.count),
+ // generate a unique ID for the event namespace
+ eventNS : '.selectize-' + (new Date().getTime()) + '-' + (Math.random().toString(36).substr(2, 5)),
highlightedValue : null,
isBlurring : false,
isOpen : false,

0 comments on commit ce78d0d

Please sign in to comment.