Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

fix(gridList): reorder tiles when ngRepeat array changes #2553

Closed
wants to merge 2 commits into from
Closed

fix(gridList): reorder tiles when ngRepeat array changes #2553

wants to merge 2 commits into from

Conversation

tarnas14
Copy link

when I tried sorting an array bound to md-grid-list ngRepeat we found that items that didn't change place were displayed incorrectly - this here fixes it (created a demo to prove it - before fix the 4th item would be displayed on 2nd from beginning or end of the md-grid-list after sorting the underlying array)

if the index of any tile changes then all tiles are rearranged by the gridList
this way elements that happen to stay at the same index of the array are also rearranged
(which was not the case before and caused weird sorting errors) - demo included

Fixes #1663
rename functions and format code correctly
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@tarnas14
Copy link
Author

signed the CLA

@googlebot
Copy link

CLAs look good, thanks!

@ThomasBurleson ThomasBurleson added this to the 0.9.0 milestone Apr 24, 2015
@ThomasBurleson ThomasBurleson self-assigned this Apr 24, 2015
@ThomasBurleson
Copy link
Contributor

@shyndman - Do you have time to review this PR. I approved let me know and I will merge.
If no time, I will review later. Thx.

@shyndman
Copy link
Contributor

Yeah, I'll be able to take a look over the weekend.

if (newIdx === oldIdx) {
return;
}
gridCtrl.reorderTiles();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take the case where someone prepends a tile to the grid -- each of the tiles that already exists in the grid will have this watch trigger, and reorderTiles will be run as many times as there are tiles. This seems like a lot of work just to add a tile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll play around with a couple things. I want to roll in a fix for #2225, since it's related.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is computation intensive, I didn't have time to go deeper into the codebase at the time, will probably try to find a better solution today, thanks for looking at it :)

@ajoslin ajoslin assigned shyndman and unassigned ThomasBurleson Apr 26, 2015
@ajoslin ajoslin added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Apr 26, 2015
@shyndman
Copy link
Contributor

@tarnas14 #2568 will fix your issue.

@shyndman shyndman closed this Apr 27, 2015
@ajoslin ajoslin removed the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Apr 27, 2015
shyndman pushed a commit that referenced this pull request Apr 28, 2015
Fixes #2553, Fixes #2225, Closes #2568.

* ng-repeated and static tiles can now be mixed
* Ordering should work properly once and for all. There's no more state
  maintenance in the grid controller. Whenever the grid re-renders, the
  DOM is queried to determine the tiles involved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants