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

fix(services): toggle pagination was not displaying all row selection #357

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ describe('PaginationService', () => {

expect(sharedService.gridOptions.enablePagination).toBeTrue();
expect(gotoSpy).toHaveBeenCalled();
expect(pubSubSpy).toHaveBeenNthCalledWith(3, `onPaginationVisibilityChanged`, { visible: true });
expect(pubSubSpy).toHaveBeenCalledWith(`onPaginationVisibilityChanged`, { visible: true });
expect(setPagingSpy).toHaveBeenCalledWith({ pageSize: mockGridOption.pagination!.pageSize, pageNum: 0 });
});
});
Expand Down
9 changes: 6 additions & 3 deletions packages/common/src/services/pagination.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,11 @@ export class PaginationService {
*
* IMPORTANT NOTE:
* The Pagination must be created on initial page load, then only after can you toggle it.
* Basically this method WILL NOT WORK to show the Pagination if it was not there from the start.
* Basically this method WILL NOT WORK to show the Pagination if it was never created from the start.
*/
togglePaginationVisibility(visible?: boolean) {
if (this.grid && this.sharedService?.gridOptions) {
const isVisible = visible !== undefined ? visible : !this.sharedService.gridOptions.enablePagination;
this.sharedService.gridOptions.enablePagination = isVisible;
this.pubSubService.publish(`onPaginationVisibilityChanged`, { visible: isVisible });

// make sure to reset the Pagination and go back to first page to avoid any issues with Pagination being offset
if (isVisible) {
Expand All @@ -312,6 +310,11 @@ export class PaginationService {
const pageSize = visible ? this._itemsPerPage : 0;
this.dataView.setPagingOptions({ pageSize, pageNum: 0 });
}

// finally toggle the "enablePagination" flag and make sure it happens AFTER the setPagingOptions is called (when using local grid)
// to avoid conflict with GridState bindSlickGridRowSelectionToGridStateChange() method
this.sharedService.gridOptions.enablePagination = isVisible;
this.pubSubService.publish(`onPaginationVisibilityChanged`, { visible: isVisible });
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/cypress/integration/example07.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Example 07 - Row Move & Checkbox Selector Selector Plugins', { retries
.should('have.length', 4);
});

it('should expect row to be moved to another row index', () => {
it('should expect the row to have moved to another row index', () => {
cy.get('.slick-viewport-top.slick-viewport-left')
.scrollTo('top');

Expand Down