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

dom-repeat filter/sort needs to be able to observe parent scope #1572

Closed
mbleigh opened this issue May 20, 2015 · 4 comments
Closed

dom-repeat filter/sort needs to be able to observe parent scope #1572

mbleigh opened this issue May 20, 2015 · 4 comments

Comments

@mbleigh
Copy link

mbleigh commented May 20, 2015

Right now, the dom-repeat filter and sort only refire on array mutations or item subproperty changes with the observe attribute. However this ignores a very common use case for filtering and sorting: user-driven changes to filter. Imagine for instance a simple list of items with a "text search" filter:

<template is="dom-repeat" filter="search">
  <span>[[item.name]]</span>
</template>

<script>
Polymer({
  search: function(item) {
    return item.name.toLowerCase().indexOf(this.q.toLowerCase()) >= 0;
  }
});
</script>

In this scenario, there is no way to make the template re-stamp when an external parameter changes (e.g. q in the example).

@mbleigh
Copy link
Author

mbleigh commented May 20, 2015

Note that because of this limitation I am currently manually calling through to the private _render() method in my app code. I didn't see any other way to achieve the desired effect.

@kevinpschaaf
Copy link
Member

Since dom-repeat isn't bound to that data (q in your example), it won't receive notifications for changes to it (as opposed to items, which is why the convenience observe property is possible).

For now, the pattern will be for external dependencies of sort/filter, the user will need to observe those properties and call render() manually to refresh the list. This doesn't quite work right now (as you noted), but I'll push a fix this morning to make that go.

@euclid1990
Copy link

@kevinpschaaf How to call render() manually from below code:

<template id="resultList" is="dom-repeat" items="{{ schedules }}" filter="filterRoom" as="schedule" index-as="scheduleId">
...
</template>

???

@kevinpschaaf
Copy link
Member

@euclid1990

this.$.resultList.render();

Call that after you change any external dependencies to the filterRoom function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants