Skip to content

Commit a2a9228

Browse files
authored
Merge pull request #3076 from klaascuvelier/fix-3075-pagination-icon
fix 3075: remove hardcoded check in pagination select icon ngIf
2 parents 6febdbd + 8165d6b commit a2a9228

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/pagination/pagination.component.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,22 @@ describe("Pagination", () => {
174174
fixture.detectChanges();
175175
expect(wrapper.pageOptions).toEqual(Array(1));
176176
});
177+
178+
it("should replace the select with a number input when the pagination threshold is reached", () => {
179+
const fixture = TestBed.createComponent(PaginationTest);
180+
const wrapper = fixture.componentInstance;
181+
fixture.detectChanges();
182+
element = fixture.debugElement.query(By.css("cds-pagination"));
183+
184+
element.componentInstance.pageSelectThreshold = 500;
185+
fixture.detectChanges();
186+
expect(element.nativeElement.querySelector(".cds--select__page-number input")).toBe(null);
187+
expect(element.nativeElement.querySelector(".cds--select__page-number select")).toBeDefined();
188+
189+
element.componentInstance.pageSelectThreshold = 2;
190+
fixture.detectChanges();
191+
expect(element.nativeElement.querySelector(".cds--select__page-number input")).toBeDefined();
192+
expect(element.nativeElement.querySelector(".cds--select__page-number select")).toBe(null);
193+
194+
});
177195
});

src/pagination/pagination.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export interface PaginationTranslations {
137137
<option *ngFor="let page of pageOptions; let i = index;" class="cds--select-option" [value]="i + 1">{{i + 1}}</option>
138138
</select>
139139
<svg
140-
*ngIf="pageOptions.length <= 1000"
140+
*ngIf="pageOptions.length <= pageSelectThreshold"
141141
cdsIcon="chevron--down"
142142
size="16"
143143
style="display: inherit;"

0 commit comments

Comments
 (0)