Skip to content

Commit

Permalink
fix(pagination): add item per page value bl-change event (#325)
Browse files Browse the repository at this point in the history
Co-authored-by: damla.demir1 <[email protected]>
  • Loading branch information
DamlaDemir and damla.demir1 authored Nov 23, 2022
1 parent 1d77755 commit ac3fdc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/pagination/bl-pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ describe('bl-pagination', () => {

select?.dispatchEvent(selectOptionEvent);

expect(el.itemsPerPage).to.equal(optionTwo?.value);
if (optionTwo) {
expect(el.itemsPerPage).to.equal(+optionTwo.value);
}

expect(el.currentPage).to.equal(1);

const undefinedEvent = new CustomEvent('bl-select', {
Expand Down
5 changes: 3 additions & 2 deletions src/components/pagination/bl-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class BlPagination extends LitElement {
/**
* Fires when the current page changes
*/
@event('bl-change') private onChange: EventDispatcher<{ selectedPage: number; prevPage: number }>;
@event('bl-change') private onChange: EventDispatcher<{ selectedPage: number; prevPage: number; itemsPerPage: number }>;

connectedCallback() {
super.connectedCallback();
Expand All @@ -114,6 +114,7 @@ export default class BlPagination extends LitElement {
this.onChange({
selectedPage: this.currentPage,
prevPage: changedProperties.get('currentPage'),
itemsPerPage: this.itemsPerPage,
});
}
}
Expand Down Expand Up @@ -171,7 +172,7 @@ export default class BlPagination extends LitElement {
}

private _selectHandler(event: CustomEvent) {
this.itemsPerPage = event?.detail[0]?.value || 100;
this.itemsPerPage = +event?.detail[0]?.value || 100;
this.currentPage = 1;
}

Expand Down

0 comments on commit ac3fdc8

Please sign in to comment.