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

Allow to clear filter text value #41

Closed
andrea-spotsoftware opened this issue Sep 27, 2017 · 4 comments
Closed

Allow to clear filter text value #41

andrea-spotsoftware opened this issue Sep 27, 2017 · 4 comments

Comments

@andrea-spotsoftware
Copy link
Contributor

andrea-spotsoftware commented Sep 27, 2017

Hello @anjmao, i'm evaluating your component in a project that i'm working on.
It's almost perfect for my needs, but there is an issue that I found about the behavior of the input (that is actually empty) when an option item is selected.

In your opinion, it's hard to do something like this?
http://plnkr.co/edit/l3phEaaU2HyAiHlJcmwQ?p=preview
I'd like to have text selectable and clearable directly from the filter input.

@andrea-spotsoftware
Copy link
Contributor Author

I could open a PR for this

@anjmao
Copy link
Member

anjmao commented Sep 28, 2017

Hi @andrea-spotsoftware, this should be easy to do. There is showClear() method in https://github.com/ng-select/ng-select/blob/master/src/lib/src/ng-select.component.html#L41
You just need to update showClear() method to also check if filterValue was set, because currently it checks only if value was selected. Let me know if you need more help :)

@anjmao anjmao added this to the Version 1.0.0 milestone Sep 28, 2017
@anjmao anjmao changed the title Nice to have: ability to select & cancel (if clearable) the selected item's text Allow to clear filter text value Sep 28, 2017
@andrea-spotsoftware
Copy link
Contributor Author

I think I have not explained well 😄
You are talking about showing the cross button during filtering, right?

I was thinking about persisting selected item's display text in the html input field, making possible to select (for copy purpose) and delete it "manually", for example with keyboard backspace or canc, having the same effect of the cross button on the right.

Probably the filter input text should be visible only when the select gets focus, because it would hide the custom label template.
Obviously, this feature makes sense only in single selection mode.

The plunker that i attached on the first message shows this behavior, if you select an item, it's clearable also with keyboard.

@anjmao
Copy link
Member

anjmao commented Sep 28, 2017

Right, now I see what you mean. I don't like the idea of adding some background color for selected text like in kendo combobox, it looks ugly :) Let just make it this as simple as clearing model value on backspace(delete) button click, this will also work in multiselect case. To select text it may require to implement ctrl+a combination but this is separate task, lets focus on making clear functionality easer to use in this task.

@andrea-spotsoftware Let me know if you want to take this, if not I can implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants