diff --git a/src/pat/select2/select2.js b/src/pat/select2/select2.js index 4895d5dfe..28eabbae5 100644 --- a/src/pat/select2/select2.js +++ b/src/pat/select2/select2.js @@ -9,6 +9,7 @@ export default Base.extend({ parser: "mockup", defaults: { separator: ",", + ajaxTimeout: 300, }, initializeValues() { @@ -196,9 +197,12 @@ export default Base.extend({ } let queryTerm = ""; + + const ajaxTimeout = parseInt(this.options.ajaxTimeout || 300, 10); + delete this.options.ajaxTimeout; this.options.ajax = $.extend( { - quietMillis: 300, + quietMillis: ajaxTimeout, data: (term, page) => { queryTerm = term; return { diff --git a/src/pat/select2/select2.test.js b/src/pat/select2/select2.test.js index 0700a3d73..a85afc8fb 100644 --- a/src/pat/select2/select2.test.js +++ b/src/pat/select2/select2.test.js @@ -4,7 +4,7 @@ import registry from "@patternslib/patternslib/src/core/registry"; import utils from "@patternslib/patternslib/src/core/utils"; import "select2"; -const SELECT2_TIMEOUT = 500; +const SELECT2_TIMEOUT = 1; describe("Select2", function () { let ajax_defaults_transport = null; @@ -106,7 +106,9 @@ describe("Select2", function () { class="pat-select2" data-pat-select2="placeholder:Search for a Value; vocabularyUrl: /select2-ajax.json; - width:20em" /> + width:20em; + ajaxTimeout: 1; + " /> `; registry.scan(document.body); await utils.timeout(1); @@ -129,7 +131,9 @@ describe("Select2", function () { class="pat-select2" data-pat-select2="placeholder:Search for a Value; vocabularyUrl: /select2-ajax.json; - width:20em" /> + width:20em; + ajaxTimeout: 1; + " /> `; registry.scan(document.body); await utils.timeout(1); @@ -151,7 +155,9 @@ describe("Select2", function () { + width:20em; + ajaxTimeout: 1; + " /> `; registry.scan(document.body); await utils.timeout(1); @@ -174,7 +180,9 @@ describe("Select2", function () { class="pat-select2" data-pat-select2="placeholder:Search for a Value; vocabularyUrl: /select2-ajax.json; - width:20em" /> + width:20em; + ajaxTimeout: 1; + " /> `; registry.scan(document.body); await utils.timeout(1); @@ -255,7 +263,9 @@ describe("Select2", function () { class="pat-select2" data-pat-select2="tags: Red,Yellow,Blue; allowNewItems: false; - width:20em" /> + width:20em; + ajaxTimeout: 1; + " /> `; registry.scan(document.body); await utils.timeout(1); @@ -278,7 +288,9 @@ describe("Select2", function () { + width:20em; + ajaxTimeout: 1; + " /> `; registry.scan(document.body); await utils.timeout(1);