material icon indicating copy to clipboard operation
material copied to clipboard

chips: $$hashKey added to objects because `track by $index` is not used

Open sazonenka opened this issue 11 years ago • 4 comments

The similar issue like in #3487

sazonenka avatar Sep 22 '15 23:09 sazonenka

Should be a trivial fix by adding track by $index to chipsDirective.js#L95

sazonenka avatar Sep 23 '15 00:09 sazonenka

Took a look at this. Just adding track by $index breaks the removal of chips since the removal happens in place. I.e., if you have ['Apple', 'Banana', 'Orange'], and remove the chip at index 1, you'd end up seeing Apple | Banana even though the model is ['Apple', 'Orange']

The ideal solution would be to allow specifying a track by at the mdChips API level, but that's a bit more complexity than a quick fix.

For future reference (for the person addressing this), here is a unit test:

      it('should not add a $$hashKey property to items', function() {
        scope.items = [{name: 'Alice'}, {name: 'Bob'}];

        buildChips(BASIC_CHIP_TEMPLATE);

        expect(scope.items[0].$$hashKey).toBeUndefined();
        expect(scope.items[1].$$hashKey).toBeUndefined();
      });

jelbourn avatar Sep 30 '15 22:09 jelbourn

What? This bug is not fixed with any effort and just close like this???

Thaina avatar Jun 28 '18 09:06 Thaina

@Thaina This was closed a couple years ago when the team did a mass closing of issues that they didn't have resources to address. If this is a concern to you now, please open a new issue with a reproduction and reference this issue.

Splaktar avatar Jul 05 '18 19:07 Splaktar