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

[Dropdown] Selecting Value in Original <select> should adjust Rendered Dropdown #2626

Closed
quentinlampin opened this issue Jul 14, 2015 · 3 comments
Milestone

Comments

@quentinlampin
Copy link

I've encountered multiple bugs when using semantic UI's dropdown to prettify a select multiple bound to an angular controller.

Issues arise

  • when the controller updates the selection, e.g. when clearing the model once the form is submitted. In that case, selection labels are not cleared, the UI does not reflect the model state.
  • when dropdown('clear') is used, causing angular to raise an error (probably trying to access the length of the selection array which has been wiped by dropdown('clear')).

The following plunker shows the encountered issues:
http://plnkr.co/edit/r93SZXKQ8w5pAzlD1TlK?p=preview

@jlukic
Copy link
Member

jlukic commented Jul 14, 2015

Thanks for the thorough test case, its appreciated.

My understanding is that the angular controller is modifying the original <select>'s option selection which you would expect would also update the multiple selection dropdown view.

However, refresh does not currently modify state to match manual adjustments to <option> selection. This would be considered an enhancement, and not a bug.

The error in the second example w/r/t clear/restoredefaults appears to be a bug. I'll have to test against the non minified source.

@jlukic jlukic added this to the 2.1 milestone Jul 14, 2015
@quentinlampin
Copy link
Author

Thanks for the feedback. I understand your opinion, yet I believe we should
address it sooner than later as I see quite a lot of cases where this
would bite again.
In my case, this was in a form that needs to be refreshed once the user
press the submit button. Think of an address bar a la gmail where you type
in a few letters and, when matched, add the recipient's name as a label in
the field. once the mail is sent, the field needs to be cleared...

Obviously, you could suggest me a solution without angular but this
framework is quite popular and that I'm sure issues like this one will pop
up often.

That said, I'm willing to help but I need help/hints as where to start.

On a side note, for the time being, it might be interesting to put a
warning in the docs on that matter.

Sorry for the long post!
Le 14 juil. 2015 08:28, "Jack Lukic" [email protected] a écrit :

Thanks for the thorough test case, its appreciated.

Refresh does not currently automatically modify state to match
selection. This would be considered an enhancement.


Reply to this email directly or view it on GitHub
#2626 (comment)
.

@jlukic jlukic changed the title [Dropdown] multiple bugs in select multiple /w angular [Dropdown] Refreshing Original <select> should adjust selected values Jul 23, 2015
@jlukic jlukic changed the title [Dropdown] Refreshing Original <select> should adjust selected values [Dropdown] Selecting Value in Original <select> should adjust Rendered Dropdown Jul 23, 2015
jlukic added a commit that referenced this issue Aug 13, 2015
jlukic added a commit that referenced this issue Aug 13, 2015
@jlukic
Copy link
Member

jlukic commented Aug 13, 2015

Dropdown now watches for change event on original <select> and automatically sets selected values. Since there is no way to generically "listen" for changes in a DOM property outside of the poorly adopted Object Watch event listeners.

2.0.8 - broken
http://jsfiddle.net/54vcr791/

2.1 - fixed
http://jsfiddle.net/j8tc5fzr/

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