Fixed reordering of collection/composite view bug.#2571
Closed
abzainuddin wants to merge 2 commits intomarionettejs:minorfrom
Closed
Fixed reordering of collection/composite view bug.#2571abzainuddin wants to merge 2 commits intomarionettejs:minorfrom
abzainuddin wants to merge 2 commits intomarionettejs:minorfrom
Conversation
This only occurs with the option reorderOnSort set to true.
Member
|
thanks for the PR @abzainuddin this has already been fixed here: ahumphreys87@e787839 It is pending release of 2.4.2 which is very close. You can track its progress here: #2532 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The collection/composite view have the option to
reorderOnSort. If this is set to true and the comparator on the collection is changed to sort from asc/desc, the sort on the collection is not correctly rendered in the DOM.What
The views have a
_indexattribute which is not updated during the sort ifreorderOnSortis set to true. If this is updated after a sort, the sort on the collection is correctly rendered in the DOM.How
_sortViews()uses theview._indexto check if the order has changed. Only if this is true it will triggerresortView(). Depending onreorderOnSort, eitherreorder()orrender()is called.Reorderwill append each childViews el in the correct order in the DOM, but not update its_index. On subsequent sorts_sortViews()will use an outdated_indexand fail. The expected behavior is described in the testwhen changing the comparator multiple times. The second added testshould reindex the viewsmakes sure the views index is updated.