GoogleWebComponents / firebase-element

Web components for the Firebase Web API
https://elements.polymer-project.org/elements/firebase-element
95 stars 72 forks source link

Selected item becomes deselected when updated in firebase #103

Open blasten opened 8 years ago

blasten commented 8 years ago

From: https://github.com/PolymerElements/iron-list/issues/131

Steps to reproduce the issue:

1) create an iron-list binded to a firebase collection element 2) select an item 3) update the item in firebase 4) the selected item becomes unselected

Firebase collection uses : this.splice('data', this.data.indexOf(oldValue), 1, value); when it needs to update a value. Iron list as a result will delete and add the element to the list and in the process it will deselect.

I am not sure if this is an issue with the list or if the firebase component that maybe should use something more clever then splice. I am not an expert so i will live you this decision to you.

eac commented 8 years ago

I'm very new to polymer, so this may be unrelated, but I'm experiencing a similar issue using dom-repeat. I'm able to work around the behavior by adding a filter to the template that always returns true.

Repro:

<template is="dom-repeat" items="{{todos}}" as="todo">
  <paper-input label="Label" value="{{todo.label}}"></paper-input>
</template>
tinders commented 8 years ago

I'm also new to polymer and having the same problem. Whenever a child is created with a dom-repeat, then it cannot seamlessly update itself via firebase. As every update fires, the data gets pushed back through from firebase and it triggers a recreation of the child. This has the effect of (for instance) blurring an input field on every key up event.

Filtering can fix it, but doesn't completely solve the issue. As in my case the dom-repeat list is dynamically populated and filtering it seems to break the functionality of the list.

Either it's a problem that anyone building complex apps with polymer/firebase faces, or we're structuring our apps incorrectly.

MeTaNoV commented 8 years ago

@blasten @eac @tinders This should be fixed thanks to #111 !