Skip to content

Bug in SortableMixin - #1537

Closed
crofty wants to merge 1 commit into
emberjs:masterfrom
crofty:sortable-mixin-remove-item-bug
Closed

crofty wants to merge 1 commit into
emberjs:masterfrom
crofty:sortable-mixin-remove-item-bug

Conversation

@crofty

@crofty crofty commented Nov 13, 2012

Copy link
Copy Markdown
Contributor

There is a bug in the SortableMixin, there is a failing test that demonstrates it below.

This test fails as all items are removed from the array proxy, the expected result is that only one item is removed.

test("removing the last item of a sorted array proxy only removes last item", function() {
  var sortedArrayProxy = Ember.ArrayProxy.create(Ember.SortableMixin,{
    sortProperties: ['id'],
    sortAscending: false,
    content: Ember.A([{id: 1}, {id: 2}])
  });
  equal( sortedArrayProxy.get('length'), 2, 'precond - array has 2 items');
  sortedArrayProxy.removeObject(sortedArrayProxy.get('lastObject'));
  equal( sortedArrayProxy.get('length'), 1, 'array has 1 item');
});

@crofty

crofty commented Nov 14, 2012

Copy link
Copy Markdown
Contributor Author

I've done a git bisect and it appears to be this commit 66edb81 that introduced the bug.

@trek

trek commented Nov 16, 2012

Copy link
Copy Markdown
Member

I'll take a look at this next week. @wagenet can you assign this to me?

@igorT

igorT commented Dec 2, 2012

Copy link
Copy Markdown
Member

This is not a bug due to a cycle. It fails because the call to replace uses the index into the sortedArray to remove an element from the original array. If you reverse the ordering, it passes for this example because both arrays are in the same order/

@wagenet

wagenet commented Dec 19, 2012

Copy link
Copy Markdown
Member

Since we're refactoring this stuff I'm not sure if we'll end up merging this. As it is, it doesn't merge cleanly, but I'm not sure if more time should be spent on it anyway.

@wagenet

wagenet commented Jan 29, 2013

Copy link
Copy Markdown
Member

Closing due to inactivity. Hopefully @igorT's proposed improvements to this area will help.

@wagenet wagenet closed this Jan 29, 2013
@crofty

crofty commented Jan 31, 2013

Copy link
Copy Markdown
Contributor Author

@wagenet please can you reopen this PR? I have verified that this is still an issue on master.

The commit that adds the failing test is here: crofty@8b4ac3c

@wagenet wagenet reopened this Jan 31, 2013
@wagenet

wagenet commented Mar 20, 2013

Copy link
Copy Markdown
Member

This is now fixed.

@wagenet wagenet closed this Mar 20, 2013
ef4 pushed a commit that referenced this pull request Jan 6, 2026
adjust benchmark close to real-life usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants