From 8f92a8ce6ab3c7278451b8ad50f75e8b2e47101e Mon Sep 17 00:00:00 2001 From: Ivan Donchev Date: Wed, 14 Nov 2018 13:59:07 +0200 Subject: [PATCH] [NG] Page size change was not triggering a state change (#1752) StateDebouncer calls added to the size setter. Signed-off-by: Ivan Donchev --- src/clr-angular/data/datagrid/datagrid.spec.ts | 13 +++++++++++++ src/clr-angular/data/datagrid/providers/page.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/clr-angular/data/datagrid/datagrid.spec.ts b/src/clr-angular/data/datagrid/datagrid.spec.ts index f821602afc..93dbfdc705 100644 --- a/src/clr-angular/data/datagrid/datagrid.spec.ts +++ b/src/clr-angular/data/datagrid/datagrid.spec.ts @@ -132,6 +132,19 @@ export default function(): void { expect(context.testComponent.nbRefreshed).toBe(1); }); + it('emits once when the page size changes', function() { + context.testComponent.nbRefreshed = 0; + const page: Page = context.getClarityProvider(Page); + page.size = 2; + context.detectChanges(); + expect(context.testComponent.nbRefreshed).toBe(1); + page.size = 5; + context.detectChanges(); + expect(context.testComponent.nbRefreshed).toBe(2); + page.resetPageSize(); + expect(context.testComponent.nbRefreshed).toBe(3); + }); + it('emits the complete state of the datagrid', function() { context.testComponent.items = [1, 2, 3, 4, 5, 6]; context.detectChanges(); diff --git a/src/clr-angular/data/datagrid/providers/page.ts b/src/clr-angular/data/datagrid/providers/page.ts index f4e0696c68..4263e7af8a 100644 --- a/src/clr-angular/data/datagrid/providers/page.ts +++ b/src/clr-angular/data/datagrid/providers/page.ts @@ -22,6 +22,7 @@ export class Page { public set size(size: number) { const oldSize = this._size; if (size !== oldSize) { + this.stateDebouncer.changeStart(); this._size = size; if (size === 0) { this._current = 1; @@ -34,6 +35,7 @@ export class Page { // the size changing means the items inside the page are different this._change.next(this._current); this._sizeChange.next(this._size); + this.stateDebouncer.changeDone(); } }