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

[V1.0] @search-change event shouldn't be emited after select an option. #70

Closed
JeOam opened this issue Jul 29, 2016 · 5 comments
Closed

Comments

@JeOam
Copy link

JeOam commented Jul 29, 2016

version: 1.0.0-beta.1

@JeOam JeOam changed the title [V1.0] @search-change event shouldn't be emited after select a option. [V1.0] @search-change event shouldn't be emited after select an option. Jul 29, 2016
@shentao
Copy link
Owner

shentao commented Jul 29, 2016

This might be because after selecting an option, the search value changes to either '' (when multiple = true) or to the selected option label (multiple = false). In the first case, I don’t want to make assumptions if we should emit the event or not because some people might want to reset the options list after selecting a value. However, it is quite easy to detect if the new search value is '' and then decide if this change should affect the component in any way.
Probably this could also be possible if you would compare current selected label with the new search value coming from the event. This is due the fact, that @update event is triggered before the @search-change event, as far as I remember.

// template
<multiselect :selected="multiselectValue" :options="someOptions" label="label" key="key" @search-change="onSearchChange"></multiselect>

// js
onSearchChange (query) {
  if (query === '' || query === this.multiselectValue.label) return
  ...stuff
}

I guess this would require some more thinking on how much assumptions we can make. Thank you for bringing this up!

@JeOam
Copy link
Author

JeOam commented Jul 29, 2016

@shentao Thank you very much for your detailed explanation. 👍

In my assumptions, an input change from typing will trigger a search event, as he/she may want to type-to-search, but while an user is going to select an option from option list, he/she must know the option list is enough, or he/she would just do the type-to-search again. He/she has no point to want to select-to-search.

query === '' || query === this.multiselectValue.label would make the search cannot be trigger when the user enter a wrong keyword and delete it and got an empty options list always.

@shentao
Copy link
Owner

shentao commented Jul 29, 2016

Yeah, that’s true. I guess I can move the emitter to the search input’s @change event. That would probably solve all problems. But this would also require to reset of the options list query after either closing or opening the multiselect.

@JeOam
Copy link
Author

JeOam commented Jul 29, 2016

@shentao or add an option to disable the select-to-search event?

@shentao
Copy link
Owner

shentao commented Jul 31, 2016

Fixed in v1.0.0

@shentao shentao closed this as completed Jul 31, 2016
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