Skip to content
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

bug: Delete last list item in collection-repeat fails #3299

Closed
jesusbotella opened this issue Mar 12, 2015 · 3 comments
Closed

bug: Delete last list item in collection-repeat fails #3299

jesusbotella opened this issue Mar 12, 2015 · 3 comments

Comments

@jesusbotella
Copy link

Type: bug

Platform: mobile webview

The new collection-repeat doesn't delete the last item in the list even though the list items array is empty.

I have an array with several items that are shown in the list by means of collection-repeat. When I delete whatever item but the last it works. But if I delete the last element, the item is still there until I tap or try to scroll.

I think it could be some view refresh that isn't executed or something like this.

I solved it by adding:

$ionicScrollDelegate.$getByHandle('listScroll').resize();

or (if deleting is done asynchronously):

$timeout(function() {
$ionicScrollDelegate.$getByHandle('listScroll').resize();
}, 150);

@ajoslin
Copy link
Contributor

ajoslin commented Mar 12, 2015

Fixing.

@ajoslin
Copy link
Contributor

ajoslin commented Mar 12, 2015

Here's the crazy logic we need:

    function makeChangeValidator() {
      var self;
      return (self = {
        dataLength: 0,
        width: 0,
        height: 0,
        resizeRequiresRefresh: function(newWidth, newHeight) {
          var requiresRefresh = self.dataLength &&
            newWidth && newWidth !== self.width &&
            newHeight && newHeight !== self.height;

          self.width = newWidth;
          self.height = newHeight;

          return !!requiresRefresh;
        },
        dataChangeRequiresRefresh: function(newData) {
          var requiresRefresh = newData.length > 0 || newData.length < self.dataLength;

          self.dataLength = newData.length;

          return !!requiresRefresh;
        }
      });
    }

Now all the cases are covered cleanly.

@jesusbotella
Copy link
Author

Thank you so much! You were so fast resolving it ;)

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants