-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Using Ember.computed.sort with itemController computed properties leads to and "Index out of range" error on resort #4831
Comments
I don't see a city button? |
I am sorry, it seems JSBin hadn't saved yet. It is there now. |
Weird... when i click between them a few times, i end up with this: Beta: 4.8 |
Yep, that is also then the "Index out of range" error is thrown. Do you see an error in the way I am using Ember.computed.sort? |
Sorry this is a bit beyond me. It seems you're sorting using :asc and a computed property and that's not mentioned in anything I could find on the net or in the API. Seems like you've found a bug to me, but I didn't even know that your usage was correct until just now! Having said that, I'm not 100% sure your code is matching up with the documentation provided at reduceComputed... http://emberjs.com/api/#method_reduceComputed and computed.sort - it might be best to provide a function rather than use a static sort order if you're going to change the sort direction... I'm not sure it's supposed to be used the way you're using it, or even if your use would work correctly... where did you get the ":asc" syntax from?? |
I saw the example here: #4308 (comment) |
Cool :) Maybe we should ask @LevelbossMike - either way, I don't think it's a great way to do something where the sort order is changing, but like I said I'm by no means an expert on this stuff. Sorry for bringing noise! |
I have found a solution to this: http://emberjs.jsbin.com/zidonulu/7/edit It seems that |
Running into this now that I've replaced using sortProperties on the array controller (because it destroys controllers on resort) with computed.sort. Can't win :/. Solution (for me) was to eliminate the |
confirmed hitting this error as well. |
I ran into this issue a couple of times lately, so I'd be quite interested in a fix. I'll also gladly help fixing it if anyone could give me a hint where to start. |
+1 |
👍 |
+1. This is a pretty nasty bug, especially considering the fact that almost every web app needs to render sorted lists. It's bitten me in literally every project I've ever worked on with Ember. EDIT: So I got around this bug by taking @nmk's comment to heart and ensuring that any updates to an array that's subject to |
+1 :( |
There are definitely some known issues with ArrayComputed which we're thinking about solutions for. |
What's the status of this issue? |
ember 2.0 removes the concept of controllers and itemControllers. |
…rjs#9462, emberjs#4919, emberjs#4231, emberjs#3706, emberjs#5596, emberjs#9485, emberjs#9492, emberjs#5319, emberjs#5268, emberjs#4831, emberjs#5558] Move away from AC/RC instead use the simpler naive enumerable methods, and rely on glimmers stable rendering for efficiency. For more complex scenarios, custom solutions should be used. @wagenet & @stefanpenner
I have made a JSBin to illustrate the issue: http://emberjs.jsbin.com/zidonulu/1/edit
As you can see the default sort is working when initially displaying the output.
After clicking on the "City" button, the
gasConsumption
values are correctly updated but the order of the list is not changed. I would expect it to change to reflect the new property values.If you then click on "Highway" and then on "City" again an "Index out of range" error is thrown.
Is this a bug I am hitting, or am I using the sorting mechanism in a wrong way?
The text was updated successfully, but these errors were encountered: