Skip to content

Commit 327fe69

Browse files
committed
feat(ui-pagination): add onMouseEnter to Pagination
INSTUI-4678
1 parent b4f9893 commit 327fe69

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/ui-pagination/src/Pagination/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ class Pagination extends Component<PaginationProps> {
331331
ref={(e) => (i === currentPage ? (this.currentPageRef = e) : null)}
332332
key={i}
333333
onClick={() => this.handleNavigation(i, currentPage)}
334+
onMouseEnter={() => this.handleOnMouseEnter(i)}
334335
current={i === currentPage}
335336
{...(this.props.screenReaderLabelPageButton
336337
? {
@@ -615,6 +616,12 @@ class Pagination extends Component<PaginationProps> {
615616
) : null
616617
}
617618

619+
handleOnMouseEnter = (page: number) => {
620+
if (typeof this.props.onMouseEnter === 'function') {
621+
this.props.onMouseEnter(page)
622+
}
623+
}
624+
618625
render() {
619626
const currentPageIndex = fastFindIndex(
620627
this.childPages,

packages/ui-pagination/src/Pagination/props.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ type PaginationOwnProps = {
182182
*/
183183
onPageChange?: (next: number, prev: number) => void
184184

185+
/**
186+
* Called when a page is hovered.
187+
*/
188+
onMouseEnter?: (page: number) => void
189+
185190
/**
186191
* Renders the visible pages
187192
*/
@@ -234,6 +239,7 @@ const propTypes: PropValidators<PropKeys> = {
234239
siblingCount: PropTypes.number,
235240
boundaryCount: PropTypes.number,
236241
onPageChange: PropTypes.func,
242+
onMouseEnter: PropTypes.func,
237243
renderPageIndicator: PropTypes.func,
238244
ellipsis: PropTypes.node
239245
}
@@ -263,7 +269,8 @@ const allowedProps: AllowedPropKeys = [
263269
'siblingCount',
264270
'boundaryCount',
265271
'renderPageIndicator',
266-
'ellipsis'
272+
'ellipsis',
273+
'onMouseEnter'
267274
]
268275

269276
type PaginationSnapshot = {

0 commit comments

Comments
 (0)