Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Filter behavior change in 1.3.6 #10419

Closed
pvenable opened this issue Dec 11, 2014 · 13 comments
Closed

Filter behavior change in 1.3.6 #10419

pvenable opened this issue Dec 11, 2014 · 13 comments
Milestone

Comments

@pvenable
Copy link

Plunker: http://plnkr.co/edit/HKQwBiVxFh6bxXzP12bB?p=preview

It looks like something changed with filtering by an object expression in 1.3.6. In the example above no items in the list render until you type in the input bound to the fooFilter model. If you change back to angular 1.3.5 you'll see that the list of items render prior to any user interaction.

Workaround is to initialize fooFilter to empty string.

caseyhoward pushed a commit to streamsend/angular.js that referenced this issue Dec 11, 2014
caseyhoward pushed a commit to streamsend/angular.js that referenced this issue Dec 11, 2014
@gkalpak
Copy link
Member

gkalpak commented Dec 11, 2014

This had been brought up in #9757 (example #9757 (comment), #9757 (comment) and #9757 (comment)) and it was intentionally implemented like this.

Note that a better approach to filtering imo (and one that does work as expected even in 1.3.6) is: http://plnkr.co/edit/6FLGXYBk0WP7P47MegmG?p=preview

But, I can imagine some people wanting this to match pre 1.3.6 behaviour, right @caitp 😄

@andrewlague
Copy link

The fact remains that this is a change of behavior in a minor release--perhaps this should be documented.

@caitp
Copy link
Contributor

caitp commented Dec 11, 2014

this is why i really wish we actually reviewed that big refactoring --- tests were passing, but it changed a bunch of things that people actually depended on, it was just too hard to spot the differences :\ we do need to change itb ack

@gkalpak
Copy link
Member

gkalpak commented Dec 11, 2014

There is already a PR for fixing this, so...

@gkalpak
Copy link
Member

gkalpak commented Dec 11, 2014

The problem with filterFilter is that it's behaviour is largely undocumented (there are a lot of possible cases and only a small fraction covered in the docs), the comparator was mistreated (in many cases the expression object played the role of the comparator) and the test coverage left several cases out. (Besides, of course, not working as expected with "deep" objects (either as items or as expression objects).)

So, basically, there was no "official" way to determine how exactly it works and people depended on behaviours often disvovered by trial and error (and then sticking to what worked).

Thus, there was no reasonable way to determine exactly what would behave differently (afaik).

As I have said before, in order to fix something broken, you have to "break its broken-ness". And that is what it takes to fix filterFilter 😞

I know; we don't want breaking changes between minor versions (by which we actually mean "we don't want fixing broken behaviour that many people are likely to depend on").
(And I do understand this btw; I am just not thrilled about it.)


@caitp: Did you mean change the undefined behaviour back or revert the whole refactoring ?

@caitp
Copy link
Contributor

caitp commented Dec 11, 2014

Change the undefined case back --- it looks like a pretty small change based on the PR.

Re: things not being tested, we should really have some test coverage reports happening :\ but it's hard since we have like 5 different test harnesses

caseyhoward pushed a commit to streamsend/angular.js that referenced this issue Dec 11, 2014
caseyhoward pushed a commit to streamsend/angular.js that referenced this issue Dec 11, 2014
caseyhoward pushed a commit to streamsend/angular.js that referenced this issue Dec 12, 2014
@caseyhoward
Copy link

@gkalpak: The only change that was needed was the one on line 199. I tried writing the following test for the other change you had and it already passed:

    var items = [{name: 'a'}, {name: 'abc'}];
    expect(filter(items, undefined)).toEqual([{name: 'a'}, {name: 'abc'}]);

I also merged the tests into one "it" block and made the test for deep objects slightly more thorough.

caseyhoward pushed a commit to streamsend/angular.js that referenced this issue Dec 12, 2014
@gkalpak
Copy link
Member

gkalpak commented Dec 12, 2014

@caseyhoward: Indeed the first change wasn't necessary, because the case typeof expression === 'undefined' is handled by the default block in the switch statement. So, I guess we can leave it out :)

@rapmue
Copy link

rapmue commented Dec 15, 2014

I'm not so sure if this is the right place, but I also found another strange behavior. It worked in 1.3.5 but it's broken in 1.3.6.

In this plunkr you'll see version 1.3.5, were you can select a type in the first select box. The options of the second selection are filtered based on the selection of the first one.
Strange for 1.3.6 is, that there is the whole selection available for the second dropdown if nothing is selected, but as soon as you select a type the second list is empty.

@gkalpak
Copy link
Member

gkalpak commented Dec 15, 2014

@rapmue: This is because of a regression in 1.3.6 and will be fixed by #10408.

@lgalfaso lgalfaso added this to the 1.3.8 milestone Dec 16, 2014
@lgalfaso
Copy link
Contributor

#10408 landed

@cspeper
Copy link

cspeper commented Feb 10, 2015

@caitp @lgalfaso this issue was closed on Dec 17th, but is still reproducible in 1.3.8 and 1.3.12:

Can we please re-open?

@pkozlowski-opensource
Copy link
Member

@cspeper could you please open a new issue with a clear reproduce scenario using plunker or similar?

petebacondarwin pushed a commit that referenced this issue Mar 2, 2015
petebacondarwin pushed a commit that referenced this issue Mar 2, 2015
hansmaad pushed a commit to hansmaad/angular.js that referenced this issue Mar 10, 2015
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.