Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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
Closed

Description

@pvenable

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.

Activity

  1. added 2 commits that reference this issue on Dec 11, 2014
    5325624
    b95d6c9
  2. gkalpak commented on Dec 11, 2014

    @gkalpak
    Member

    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 😄

  3. andrewlague commented on Dec 11, 2014

    @andrewlague

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

  4. caitp commented on Dec 11, 2014

    @caitp
    Contributor

    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

  5. gkalpak commented on Dec 11, 2014

    @gkalpak
    Member

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

  6. gkalpak commented on Dec 11, 2014

    @gkalpak
    Member

    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 ?

  7. caitp commented on Dec 11, 2014

    @caitp
    Contributor

    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

  8. added 3 commits that reference this issue on Dec 11, 2014
    1b6b857
    e93024f
    5718e12
  9. caseyhoward commented on Dec 12, 2014

    @caseyhoward

    @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.

  10. added a commit that references this issue on Dec 12, 2014
    df5f775
  11. gkalpak commented on Dec 12, 2014

    @gkalpak
    Member

    @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 :)

  12. rapmue commented on Dec 15, 2014

    @rapmue

    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.

  13. gkalpak commented on Dec 15, 2014

    @gkalpak
    Member

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

  14. added this to the 1.3.8 milestone on Dec 16, 2014
  15. lgalfaso commented on Dec 17, 2014

    @lgalfaso
    Contributor

    #10408 landed

  16. cspeper commented on Feb 10, 2015

    @cspeper

    @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?

  17. pkozlowski-opensource commented on Feb 11, 2015

    @pkozlowski-opensource
    Member

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

  18. added 2 commits that reference this issue on Mar 2, 2015
    63b9956
    c62fa6b
  19. added a commit that references this issue on Mar 10, 2015
    71e19d6
  20. added a commit that references this issue on Aug 8, 2015
    c93f5f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions