Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

removeSelected removes any pre-selected item from dropdown #1672

Closed
fiznool opened this issue Jun 20, 2016 · 13 comments
Closed

removeSelected removes any pre-selected item from dropdown #1672

fiznool opened this issue Jun 20, 2016 · 13 comments

Comments

@fiznool
Copy link
Contributor

fiznool commented Jun 20, 2016

Bug description:

When linking the ui-select component to a model which points to an item in the items array, the preselected item is not displayed in the dropdown list.

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/bMlvGYc0Jfq3PX8NQcpv?p=preview

Notice that although 'Amalie' is preselected, she is not displayed in the dropdown list.

Version of Angular, UI-Select, and Bootstrap/Select2/Selectize CSS

Angular: 1.5.0

UI-Select: 0.18.0

Bootstrap/Select2/Selectize CSS (if applicable): 3.1.1

@fiznool
Copy link
Contributor Author

fiznool commented Jun 20, 2016

It's worth noting that this situation works fine with 0.17.1.

A temporary fix is to add a remove-selected="false" attribute to the <ui-select> tag.

@p10
Copy link

p10 commented Jun 24, 2016

I think it's not a bug but feature ;-) 3ad084f

You can switch it back to false globaly in configuration section:

app.config(function(uiSelectConfig) {
  uiSelectConfig.removeSelected = false;
});

@fiznool
Copy link
Contributor Author

fiznool commented Jun 24, 2016

@p10 I tried this but it didn't work... I think the config block is run after the uiSelectController is created, and so this code which caches the removeSelected flag is still true.

@user378230
Copy link
Contributor

user378230 commented Jun 24, 2016

/cc @dondi any chance you could take a look at this?

@dondi
Copy link
Contributor

dondi commented Jun 24, 2016

OK I'll investigate.

@dondi
Copy link
Contributor

dondi commented Jun 26, 2016

Quick update: I have been able to replicate this behavior and have written a unit test for it. Based on what I can replicate, the previous version (0.17.1) indeed does not remove the item from the dropdown, but the highlighted item when the dropdown is displayed for the first time does not match the pre-selected object either (initial highlighted item is always the first one).

Is that what others saw in the previous release? If this is the behavior that everyone is used to, then even if it is not entirely correct, it will be useful to know that just reverting to this will suffice. However if I’m not seeing the correct prior behavior, or if the preference is to get this working completely right, then that changes the code trajectory a bit.

Please advise—thanks!

@fiznool
Copy link
Contributor Author

fiznool commented Jun 26, 2016 via email

dondi added a commit to dondi/ui-select that referenced this issue Jun 27, 2016
Make sure that `removeSelected` only affects `multiple`s, include unit test, and add comment in demo examples.

Addresses angular-ui#1672 and possibly angular-ui#1681
@dondi
Copy link
Contributor

dondi commented Jun 27, 2016

OK, potential fix available at #1690 …I toggled between master and this to make sure that the incorrect behavior reported here was definitely gone in the new version. All unit tests still pass, plus one more unit test was added specifically for this situation. Hope this does the trick, let me know :)

@dondi
Copy link
Contributor

dondi commented Jun 27, 2016

BTW @fiznool I was able to get this PR to implement the fully correct behavior where the pre-existing selection in the model is indeed highlighted from the get-go in the ui-select element. Thank you!

@mharmuth
Copy link

@p10 For me, it works when changing the value to false in configuration. Thanks ;)

@fiznool
Copy link
Contributor Author

fiznool commented Jun 30, 2016

@dondi I've just tested with a manually created build using gulp and all works nicely, thanks!

Could you cut a new release? I'm installing using bower and so I need the dist folder to contain the latest code in order to update my codebase properly.

@dondi
Copy link
Contributor

dondi commented Jun 30, 2016

Greetings @fiznool —Glad to hear your tests look good! I will have to defer to @user378230 with regard to releases.

@ptata-rythmos
Copy link

ptata-rythmos commented Jun 4, 2019

I have used LimitTo filter in ui-select where i have millions of items in my dropdown. So preselected items are not visible in select-match

pre-selected item in dropdown is not populated, when reopen the window and item is not in filtered 100 items
empty

Preselected item is populated when the item is in filtered 100 list.
item-in-selected-100

when no item is selected
no-select

I used remove-selected="false" but no use.
can somebody help me out.

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

No branches or pull requests

6 participants