adopted-ember-addons / adopted-ember-addons/ember-collection

filtering changes the order of the DOM elements

Đang mở
#97 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
235
Fork
81
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

If I apply a filter a list and take it away, DOM elements are inserted in a seemingly random order. This might be expected or even intentional, and I'm not sure if it's ember-collection's problem, but just wanted to point it out.

So if I have these items:

``` js
let items = [
{name: "Item 1"},
{name: "Item 2"},
{name: "Item 3"},
{name: "Item 4"},
{name: "Item 5"},
...
{name: "Item 10000"},
]
```

and

``` hbs


{{#ember-collection items=items cell-layout=(fixed-grid-layout 500 50) as |item index| }}
{{item.name}}
{{/ember-collection}}

```

I get the HTML:

``` html






Item 1

Item 2

Item 3

Item 4

Item 5




```

So far so good.

But if I apply a filter to `items` (lets say so `items` is only even number items) the HTML becomes something like this (note the random order)

``` html





Item 14

Item 2

Item 12

Item 4

Item 10

Item 8






```

The positions of the elements remains accurate (with absolute positioning), so the UI looks right.

The only use case for me right now is that I'm using `:nth-child(odd)` to give alternating row colors, and the random DOM ordering breaks that.

`:nth-child(odd)` CSS _also_ breaks with just regular scrolling because as new DOM elements are inserted, if the height of the parent can display an odd number of elements `n`, every `n` elements, there is a duplication. But this is less my concern than the random ordering on filter.

Here's a sample app to demonstrate: https://github.com/mehulkar/ember-collection-example

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.