Skip to content

Commit

Permalink
Fix(web-react): Failing type in PaginationLink #DS-1586
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed Nov 21, 2024
1 parent b2fef7b commit bca92a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
11 changes: 4 additions & 7 deletions packages/web-react/src/components/Pagination/PaginationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
'use client';

import classNames from 'classnames';
import React, { ElementType, ForwardedRef, forwardRef } from 'react';
import React, { ElementType, forwardRef } from 'react';
import { useStyleProps } from '../../hooks';
import { SpiritPaginationLinkProps } from '../../types';
import { PolymorphicRef, SpiritPaginationLinkProps } from '../../types';
import { VisuallyHidden } from '../VisuallyHidden';
import { usePaginationStyleProps } from './usePaginationStyleProps';

/* We need an exception for components exported with forwardRef */
/* eslint no-underscore-dangle: ['error', { allow: ['_PaginationLink'] }] */
const _PaginationLink = <E extends ElementType = 'a'>(
props: SpiritPaginationLinkProps<E>,
ref: ForwardedRef<HTMLAnchorElement>,
) => {
const _PaginationLink = <E extends ElementType = 'a'>(props: SpiritPaginationLinkProps<E>, ref: PolymorphicRef<E>) => {
const { elementType: ElementTag = 'a', accessibilityLabel, isCurrent, pageNumber, ...restProps } = props;

const { classProps } = usePaginationStyleProps({ isCurrent });
Expand All @@ -31,6 +28,6 @@ const _PaginationLink = <E extends ElementType = 'a'>(
);
};

export const PaginationLink = forwardRef<HTMLAnchorElement, SpiritPaginationLinkProps>(_PaginationLink);
const PaginationLink = forwardRef<HTMLAnchorElement, SpiritPaginationLinkProps<ElementType>>(_PaginationLink);

export default PaginationLink;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React from 'react';
import { SpiritUncontrolledPaginationProps } from '../../types/pagination';
import { ClickEvent, SpiritUncontrolledPaginationProps } from '../../types';
import Pagination from './Pagination';
import PaginationItem from './PaginationItem';
import PaginationLink from './PaginationLink';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const UncontrolledPagination = (props: SpiritUncontrolledPaginationProps)
href="#"
isCurrent={currentPage === pageNumber}
pageNumber={pageNumber}
onClick={(event) => {
onClick={(event: ClickEvent) => {
event.preventDefault();
handlePageChange(pageNumber);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UsePaginationProps } from '../../types/pagination';

export const usePagination = ({ totalPages, onChange, defaultPage, visiblePages }: UsePaginationProps) => {
const [currentPage, setCurrentPage] = useState(defaultPage <= 0 || defaultPage > totalPages ? 1 : (defaultPage ?? 1));
const [pages, setPagesArray] = useState([visiblePages] ?? [5]);
const [pages, setPagesArray] = useState([visiblePages]);

useMemo(() => {
const currentVisiblePages = visiblePages > totalPages ? totalPages : visiblePages;
Expand Down

0 comments on commit bca92a5

Please sign in to comment.