From 3ee7b18886888d11ed55f7c2ff779d6e6de99cd8 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 11 Jan 2018 09:54:39 +0100 Subject: [PATCH] FIX: disable by default limitMatches --- .../select-kit/components/multi-select.js.es6 | 6 +++++- .../select-kit/components/select-kit.js.es6 | 2 +- .../select-kit/components/single-select.js.es6 | 6 +++++- .../components/multi-select-test.js.es6 | 14 ++++++++++++++ .../components/single-select-test.js.es6 | 15 ++++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/select-kit/components/multi-select.js.es6 b/app/assets/javascripts/select-kit/components/multi-select.js.es6 index 92f96c26a4..616af38241 100644 --- a/app/assets/javascripts/select-kit/components/multi-select.js.es6 +++ b/app/assets/javascripts/select-kit/components/multi-select.js.es6 @@ -110,7 +110,11 @@ export default SelectKitComponent.extend({ computedContent = this.filterComputedContent(computedContent, computedValues, filter); } - return computedContent.slice(0, this.get("limitMatches")); + if (this.get("limitMatches")) { + return computedContent.slice(0, this.get("limitMatches")); + } + + return computedContent; }, baseHeaderComputedContent() { diff --git a/app/assets/javascripts/select-kit/components/select-kit.js.es6 b/app/assets/javascripts/select-kit/components/select-kit.js.es6 index 66aa76c8ec..cf033a2d46 100644 --- a/app/assets/javascripts/select-kit/components/select-kit.js.es6 +++ b/app/assets/javascripts/select-kit/components/select-kit.js.es6 @@ -60,7 +60,7 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi allowInitialValueMutation: false, content: null, computedContent: null, - limitMatches: 100, + limitMatches: null, nameChanges: false, allowContentReplacement: false, collectionHeader: null, diff --git a/app/assets/javascripts/select-kit/components/single-select.js.es6 b/app/assets/javascripts/select-kit/components/single-select.js.es6 index c0f0c3349e..2dfe76904a 100644 --- a/app/assets/javascripts/select-kit/components/single-select.js.es6 +++ b/app/assets/javascripts/select-kit/components/single-select.js.es6 @@ -88,7 +88,11 @@ export default SelectKitComponent.extend({ computedContent = this.filterComputedContent(computedContent, computedValue, filter); } - return computedContent.slice(0, this.get("limitMatches")); + if (this.get("limitMatches")) { + return computedContent.slice(0, this.get("limitMatches")); + } + + return computedContent; }, @computed("computedValue", "computedContent.[]") diff --git a/test/javascripts/components/multi-select-test.js.es6 b/test/javascripts/components/multi-select-test.js.es6 index 1bb5f940be..454a45dac6 100644 --- a/test/javascripts/components/multi-select-test.js.es6 +++ b/test/javascripts/components/multi-select-test.js.es6 @@ -145,3 +145,17 @@ componentTest('interactions', { }); } }); + +componentTest('with limitMatches', { + template: '{{multi-select content=content limitMatches=2}}', + + beforeEach() { + this.set('content', ['sam', 'jeff', 'neil']); + }, + + test(assert) { + this.get('subject').expand(); + + andThen(() => assert.equal(this.get('subject').el().find(".select-kit-row").length, 2)); + } +}); diff --git a/test/javascripts/components/single-select-test.js.es6 b/test/javascripts/components/single-select-test.js.es6 index 1f7c41807d..2e39a6dd40 100644 --- a/test/javascripts/components/single-select-test.js.es6 +++ b/test/javascripts/components/single-select-test.js.es6 @@ -481,7 +481,6 @@ componentTest('with title', { } }); - componentTest('support modifying header computed content through plugin api', { template: '{{single-select content=content}}', @@ -505,3 +504,17 @@ componentTest('support modifying header computed content through plugin api', { andThen(() => clearCallbacks()); } }); + +componentTest('with limitMatches', { + template: '{{single-select content=content limitMatches=2}}', + + beforeEach() { + this.set('content', ['sam', 'jeff', 'neil']); + }, + + test(assert) { + this.get('subject').expand(); + + andThen(() => assert.equal(this.get('subject').el().find(".select-kit-row").length, 2)); + } +});