miguelcobain / ember-yeti-table

Yeti Table
https://miguelcobain.github.io/ember-yeti-table
MIT License
61 stars 15 forks source link

pageSize reverts to parameter default on reRender #201

Open cah-john-ryan opened 4 years ago

cah-john-ryan commented 4 years ago

I am seeing an unexpected behavior after changing the default pageSize and then changing a property on any Ember Data record that is being rendered in the Yeti table. I am seeing the pageSize revert back to the default value that I have provided.

ex. Clone and run https://github.com/cah-johnryan/ember-yeti-table/tree/paging-issue Navigate to: http://localhost:4200/docs/pagination (I have modified the example on this doc to demonstrate the situation)

I will be happy to try and help build changes in a PR. Let me know. Thanks.

cah-brian-gantzler commented 4 years ago

I think the issue here is that when the page size changes, it is not communicated to the parent container. So any time pageSize is passed into yeti table this could be a problem.

Yeti table component should contain an onPageSizeChanged action to the parent container know about the change.

Alternately, if the pagination component is being used, should allow for communication of a page size change, rather than send the action all the way through to the table. Currently the pagination component takes a hash of actions, rather than specify each action, this makes it more difficult to provide override just one of the actions.

I would suggest both creating an action of the table itself, and changing the interface of the pagination control to receive its actions independently instead of as the hash.

cah-john-ryan commented 4 years ago

I have implemented changes in my application to track changes in pageSize external to yeti-table so that re-renders don't lose the desired page size. I am closing this issue as I personally do not need this addressed.

miguelcobain commented 4 years ago

I'm reopening this so I don't forget to address this.

cah-brian-gantzler commented 4 years ago

I had John (Andy) fix it the way he did because we did our on pagination control so it was easy to just hook into that controls onPageSizeChanged.

If the pagesize is passed into yeti, and then the data or filter or anything else also passed in changes, the page size gets passed in again. You dont know if they intended to repass or not.

What you would have to do is make a onPageSizeChanged action on table, and the consumer would have to mut the pagesize they passed in (so you cant hardcode the page size, its got to be a variable)