Skip to content

Commit a8351f0

Browse files
authored
fix(grid-paginator): Fix paginator losing default resource strings on partial override (#16886)
1 parent ef85d87 commit a8351f0

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

projects/igniteui-angular/paginator/src/paginator/paginator.component.spec.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,55 @@ describe('IgxPaginator with default settings', () => {
231231
expect(totalPages.innerText).toBe('1');
232232
});
233233

234+
it('should display the pager text ("of") in page navigation', () => {
235+
const fix = TestBed.createComponent(DefaultPaginatorComponent);
236+
fix.detectChanges();
237+
238+
const pageNavTextDiv = fix.debugElement.query(By.css('.igx-page-nav__text')).nativeElement;
239+
const spans = pageNavTextDiv.querySelectorAll('span');
240+
const paginator = fix.componentInstance.paginator;
241+
242+
// Should have 3 spans: current page, "of" text, total pages
243+
expect(spans.length).toBe(3);
244+
245+
// Check current page
246+
expect(spans[0].innerText.trim()).toBe('1');
247+
248+
// Check the "of" text
249+
expect(spans[1].innerText.trim()).toBe('of');
250+
251+
// Check total pages
252+
expect(spans[2].innerText.trim()).toBe('3');
253+
254+
// Verify the resource string is set
255+
expect(paginator.resourceStrings.igx_paginator_pager_text).toBe('of');
256+
});
257+
258+
it('should preserve default resource strings when partial resourceStrings are provided', () => {
259+
const fix = TestBed.createComponent(DefaultPaginatorComponent);
260+
fix.detectChanges();
261+
262+
const paginator = fix.componentInstance.paginator;
263+
264+
// Set only a partial resource string (only override label)
265+
paginator.resourceStrings = { igx_paginator_label: 'Custom per page' };
266+
fix.detectChanges();
267+
268+
const pageNavTextDiv = fix.debugElement.query(By.css('.igx-page-nav__text')).nativeElement;
269+
const spans = pageNavTextDiv.querySelectorAll('span');
270+
271+
// Verify the custom label is set
272+
expect(paginator.resourceStrings.igx_paginator_label).toBe('Custom per page');
273+
274+
// Verify the pager text ("of") is still present from defaults
275+
expect(paginator.resourceStrings.igx_paginator_pager_text).toBe('of');
276+
expect(spans[1].innerText.trim()).toBe('of');
277+
278+
// Verify other default strings are also preserved
279+
expect(paginator.resourceStrings.igx_paginator_first_page_button_text).toBe('Go to first page');
280+
expect(paginator.resourceStrings.igx_paginator_next_page_button_text).toBe('Next page');
281+
});
282+
234283
});
235284

236285
describe('IgxPaginator with custom settings', () => {

projects/igniteui-angular/paginator/src/paginator/paginator.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class IgxPaginatorComponent implements IgxPaginatorToken {
256256
*/
257257
@Input()
258258
public set resourceStrings(value: IPaginatorResourceStrings) {
259-
this._resourceStrings = Object.assign({}, this._resourceStrings, value);
259+
this._resourceStrings = Object.assign({}, this.resourceStrings, value);
260260
}
261261

262262
/**

0 commit comments

Comments
 (0)