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

Store: architectural problems if item's id property is not "id" #463

Open
wkeese opened this issue Sep 2, 2016 · 0 comments
Open

Store: architectural problems if item's id property is not "id" #463

wkeese opened this issue Sep 2, 2016 · 0 comments

Comments

@wkeese
Copy link
Member

wkeese commented Sep 2, 2016

This problem showed up when multiple items in a List were getting the d-selected class. This was caused by deliteful/List#_createItemRenderer() calling delite/Selection#isSelected(renderItem), which
called delite/Store#getIdentity(renderItem), which returned undefined.

Why did getIdentity() return undefined? Because it was expecting a store item rather than a render item, and the render item and store item were storing the identity in a different property. The render item was {id: "foo"} whereas the corresponding store item was {value: "foo"}. (Note that the store had idProperty: "value".)

So the problem starts with delite/Store#getIdentity(item). The documentation doesn't specify whether item is a store item or a render item. But it's worse than that: sometimes getIdentity() is called on store items, and other times it's called on render items.

  1. delite/StoreMap#itemToRenderItem() depends on getIdentity() working on store items.
  2. deliteful/List#_createItemRenderer() calls delite/Selection#isSelected(renderItem).
    delite/Selection#isSelected() calls delite/Store#getIdentity(renderItem).

Note that delite/Selection doesn’t seem to have an idea of the difference between store items and render items. And Combobox sets Selection#selectedItem to the renderItem. So Selection#getIdentity(item) should probably also take a renderItem. But Selection#getIdentity() and Store#getIdentity() are the same method because List extends both Store and Selection.

Finally, note that StoreMap#itemToRenderItem() hardcodes the render item's id property to be called id.

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

No branches or pull requests

1 participant