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

Setting a sane selected value when selected item is removed/replaced from the DOM #65

Open
zinkkrysty opened this issue Sep 28, 2015 · 4 comments

Comments

@zinkkrysty
Copy link

Consider a dynamic list, as it's typical in many apps. When this list changes, and the selected value doesn't exist anymore in the new list, what should it equal to afterwards?

There are 2 example cases and I am writing failing tests for both right now, but I want to start a discussion on what you think it should happen to the selected property:

  1. You use an iron-selector with attr-for-selected set to my-attr. The children are generated with a dom-repeat, and the currently selected item has my-attr=foo. You then swap the children with different ones. The initially selected value foo is no longer found in the new set of items. What is the selected item and its value?
  2. You have a list of n items (item0, item1, item2 ... itemn), and the user selects the last item (itemn). As a result to another user action, itemn gets removed from the list. What should the selected item be now?
@zinkkrysty zinkkrysty changed the title Setting a sane value when selected item is removed/replaced from the DOM Setting a sane selected value when selected item is removed/replaced from the DOM Sep 28, 2015
@zinkkrysty
Copy link
Author

Can someone confirm, is this actually working sane enough right now, maybe I'm seeing issues where there are none...? It all started with me trying to debug a paper-dropdown-menu and a paper-menu problem with dynamic children...

@mattprivman
Copy link

Having the same problem. Did you manage to find a workaround for this?

@mattprivman
Copy link

Best solution so far seems to be firing iron-select with an object containing a label and a value property, as seen here. Credit to @davidrissato from the Polymer slack group.

@davidrissato
Copy link

@mattppp: I'm sorry, but I've changed by mistake my original example with another thing completely different. You can find the old example in this snapshot: http://jsbin.com/raleni/7/edit?html,output

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

4 participants