diff --git a/addon/components/power-select-infinity.js b/addon/components/power-select-infinity.js index b6b5dd4..ec44452 100644 --- a/addon/components/power-select-infinity.js +++ b/addon/components/power-select-infinity.js @@ -20,6 +20,7 @@ export default Component.extend({ estimateHeight: 28, bufferSize: 5, staticHeight: false, + minCharacters: 0, fastboot: computed(function() { return getOwner(this).lookup(`service:fastboot`); }), @@ -59,6 +60,9 @@ export default Component.extend({ select.actions.choose(null); } } + }, + onInput(text) { + return text.length >= get(this, 'minCharacters'); } } }); diff --git a/addon/templates/components/power-select-infinity.hbs b/addon/templates/components/power-select-infinity.hbs index cfe0c03..199b9c8 100644 --- a/addon/templates/components/power-select-infinity.hbs +++ b/addon/templates/components/power-select-infinity.hbs @@ -26,7 +26,7 @@ onchange=onchange onclose=onclose onfocus=(action "handleFocus") - oninput=oninput + oninput=(action "onInput") onkeydown=(action "onKeyDown") onopen=onopen opened=opened @@ -89,7 +89,7 @@ onchange=onchange onclose=onclose onfocus=(action "handleFocus") - oninput=oninput + oninput=(action "onInput") onkeydown=(action "onKeyDown") onopen=onopen opened=opened diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index cc7e4a5..712d91b 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -52,4 +52,22 @@ {{user.name}} {{/power-select-infinity}} + + +
+
+ With min length + {{#power-select-infinity + search=(action 'search') + loadMore=(action 'loadMore') + selected=selected + onchange=(action (mut selected)) + extra=(hash labelPath="name") + inputClass="form-control" + minCharacters=3 + loadingComponent='loading-component' + as |user|}} + {{user.name}} + {{/power-select-infinity}} +
\ No newline at end of file