Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Min search #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addon/components/power-select-infinity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}),
Expand Down Expand Up @@ -59,6 +60,9 @@ export default Component.extend({
select.actions.choose(null);
}
}
},
onInput(text) {
return text.length >= get(this, 'minCharacters');
}
}
});
4 changes: 2 additions & 2 deletions addon/templates/components/power-select-infinity.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
onchange=onchange
onclose=onclose
onfocus=(action "handleFocus")
oninput=oninput
oninput=(action "onInput")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bakerac4 it looks like the consuming app is losing the ability to provide their own oninput action handler with this change. maybe we could add a tryInvoke(this, 'oninput', [text]) to the onInput action to maintain this?

onkeydown=(action "onKeyDown")
onopen=onopen
opened=opened
Expand Down Expand Up @@ -89,7 +89,7 @@
onchange=onchange
onclose=onclose
onfocus=(action "handleFocus")
oninput=oninput
oninput=(action "onInput")
onkeydown=(action "onKeyDown")
onopen=onopen
opened=opened
Expand Down
18 changes: 18 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@
{{user.name}}
{{/power-select-infinity}}
</div>
</div>

<div class="row justify-content-center">
<div class="col-4">
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}}
</div>
</div>