Skip to content

Commit

Permalink
(patch) fix selectedItem notification
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinecula authored and nomego committed Mar 19, 2019
1 parent 2f26ef8 commit a744403
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cosmoz-data-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
type: Object,
notify: true,
readOnly: true,
computed: '_getItem(selected, items)'
computed: '_getItem(selected, items.*)'
},

/**
Expand Down Expand Up @@ -601,7 +601,8 @@
}

_getItem(index, items = this.items) {
return items[index];
const arr = items.base ? items.base : items;
return arr[index];
}

_resetElement(index) {
Expand Down
9 changes: 7 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ <h3>Basic <code>cosmoz-data-nav</code>.</h3>
<dom-bind id="basic">
<template is="dom-bind">
<cosmoz-data-nav items="[[ items ]]" index-as="index" as="item" on-need-data="onNeedData" selected="{{ selected }}"
selected-item="{{selItem}}"
hash-param="tt">
<template>
<cosmoz-demo-view class="fit layout vertical" item="{{ item }}" index="[[index]]" data-idx$="{{ computeColorIndex(index) }}"
prev-disabled="[[ prevDisabled ]]" next-disabled="[[ nextDisabled ]]"></cosmoz-demo-view>
</template>
</cosmoz-data-nav>
<paper-textarea value="{{ computeJSON(selected, items.*) }}">
<paper-textarea>
</paper-textarea>
<div>Selected: [[toJSON(selItem)]]</div>
</template>
</dom-bind>
</template>
Expand Down Expand Up @@ -92,6 +94,9 @@ <h3>Basic <code>cosmoz-data-nav</code>.</h3>
basic.computeJSON = function (index) {
return JSON.stringify(this.items[index]);
};
basic.toJSON = function (item) {
return JSON.stringify(item);
};
basic.set('items', items);
});

Expand All @@ -100,4 +105,4 @@ <h3>Basic <code>cosmoz-data-nav</code>.</h3>
</script>
</body>

</html>
</html>

0 comments on commit a744403

Please sign in to comment.