iron-list icon indicating copy to clipboard operation
iron-list copied to clipboard

Filtering and selecting preserves actions taken on unrelated elements

Open evanbechtol opened this issue 7 years ago • 5 comments

Description & Actual Outcome

The iron-list element is incorrectly binding actions across elements, on what appear to be indices. When filtering the list of elements in an iron-list, the actions perform on the filtered list are bound to the indices. When the filter is removed, the actions performed are then incorrectly reflected on the unfiltered list indices.

Expected outcome

When performing actions on a filtered list, the unfiltered list should not be affected. The actions should be bound to the specific element that they were performed on initially.

Live Demo

Live Demo (Plunkr)

Steps to reproduce

  1. Initial State selectall0

  2. Search for a project in the list selectall1

  3. In that project, check the select all checkbox selectall2

  4. Clear the search input, and expand the first project in the list, notice that the items appear checked now, even though their data has not been retrieved selectall3

  5. Uncheck the select all checkbox that is incorrectly checked selectall4

  6. Go back to the project that was originally filtered on, notice that the checkboxes are now unchecked as well selectall5

Browsers Affected

  • [x] Chrome
  • [x] Firefox
  • [ ] Safari 9
  • [ ] Safari 8
  • [ ] Safari 7
  • [ ] Edge
  • [ ] IE 11
  • [ ] IE 10

evanbechtol avatar May 18 '17 13:05 evanbechtol

In your example, the checked state of a project is correctly bound to the filteredProjectData array, but when you toggle "select all", filteredProjectData is reset, so you lose the checked state.

keanulee avatar May 18 '17 20:05 keanulee

This is true, but shouldn't​ iron-list then also lose the checked state?

On Thu, May 18, 2017, 3:59 PM Keanu Lee [email protected] wrote:

In your example, the checked state of a project is correctly bound to the filteredProjectData array, but when you toggle "select all", filteredProjectData is reset, so you lose the checked state.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PolymerElements/iron-list/issues/444#issuecomment-302539845, or mute the thread https://github.com/notifications/unsubscribe-auth/AJn-AzZ4vTFgINp8d1nvKyC_0972ioxyks5r7LFFgaJpZM4NfQDl .

evanbechtol avatar May 18 '17 21:05 evanbechtol

The first <workplan-filter-list> is also being recycled, and when you clear the search filter the first <workplan-filter-list> will have its selectAllChecked property set, so that's why it's checked. Haven't tried using nested <iron-list>s before - interesting use case, but not 100% sure it'll work as expected.

keanulee avatar May 18 '17 21:05 keanulee

So is there a way to force the iron-list to provide the behavior that I am stating above? Am I doing something incorrectly, or is this in fact an issue?

On Thu, May 18, 2017, 4:33 PM Keanu Lee [email protected] wrote:

The first is also being recycled, and when you clear the search filter the first will have its selectAllChecked property set, so that's why it's checked. Haven't tried using nested s before - interesting use case, but not 100% sure it'll work as expected.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PolymerElements/iron-list/issues/444#issuecomment-302547993, or mute the thread https://github.com/notifications/unsubscribe-auth/AJn-A0sonnzj2gxG8Igpc67gHD9q5cbEks5r7Lk4gaJpZM4NfQDl .

evanbechtol avatar May 18 '17 21:05 evanbechtol

I would try making project.selectAllChecked a property on the project and bind to that.

keanulee avatar May 18 '17 22:05 keanulee