Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-core/src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ToggleTemplate, PaginationToggleTemplateProps } from './ToggleTemplate'
import styles from '@patternfly/react-styles/css/components/Pagination/pagination';
import { css } from '@patternfly/react-styles';
import { fillTemplate } from '../../helpers';
import { Navigation } from './Navigation';
import { PaginationNavigation } from './PaginationNavigation';
import { PaginationOptionsMenu } from './PaginationOptionsMenu';
import { useOUIAProps, OUIAProps } from '../../helpers';
import { formatBreakpointMods } from '../../helpers/util';
Expand Down Expand Up @@ -342,7 +342,7 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
appendTo={menuAppendTo}
/>
)}
<Navigation
<PaginationNavigation
pagesTitle={titles.page}
pagesTitlePlural={titles.pages}
toLastPageAriaLabel={titles.toLastPageAriaLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { OnSetPage } from './Pagination';
import { pluralize, PickOptional } from '../../helpers';
import { KeyTypes } from '../../helpers/constants';

export interface NavigationProps extends React.HTMLProps<HTMLElement> {
export interface PaginationNavigationProps extends React.HTMLProps<HTMLElement> {
/** Additional classes for the pagination navigation container. */
className?: string;
/** Accessible label for the input displaying the current page. */
Expand Down Expand Up @@ -60,18 +60,18 @@ export interface NavigationProps extends React.HTMLProps<HTMLElement> {
onSetPage: OnSetPage;
}

export interface NavigationState {
export interface PaginationNavigationState {
userInputPage?: number | string;
}

class Navigation extends Component<NavigationProps, NavigationState> {
static displayName = 'Navigation';
constructor(props: NavigationProps) {
class PaginationNavigation extends Component<PaginationNavigationProps, PaginationNavigationState> {
static displayName = 'PaginationNavigation';
constructor(props: PaginationNavigationProps) {
super(props);
this.state = { userInputPage: this.props.page };
}

static defaultProps: PickOptional<NavigationProps> = {
static defaultProps: PickOptional<PaginationNavigationProps> = {
className: '',
isDisabled: false,
isCompact: false,
Expand Down Expand Up @@ -104,7 +104,7 @@ class Navigation extends Component<NavigationProps, NavigationState> {
}

private onChange(event: React.FormEvent<HTMLInputElement>, lastPage: number): void {
const inputPage = Navigation.parseInteger(event.currentTarget.value, lastPage);
const inputPage = PaginationNavigation.parseInteger(event.currentTarget.value, lastPage);
this.setState({ userInputPage: Number.isNaN(inputPage) ? event.currentTarget.value : inputPage });
}

Expand All @@ -126,7 +126,7 @@ class Navigation extends Component<NavigationProps, NavigationState> {
'ArrowDown'
];
if (event.key === KeyTypes.Enter) {
const inputPage = Navigation.parseInteger(this.state.userInputPage, lastPage);
const inputPage = PaginationNavigation.parseInteger(this.state.userInputPage, lastPage);
onPageInput(event, Number.isNaN(inputPage) ? page : inputPage);
this.handleNewPage(event, Number.isNaN(inputPage) ? page : inputPage);
} else if (!/^\d*$/.test(event.key) && !allowedKeys.includes(event.key)) {
Expand All @@ -141,7 +141,7 @@ class Navigation extends Component<NavigationProps, NavigationState> {
return onSetPage(_evt, newPage, perPage, startIdx, endIdx);
};

componentDidUpdate(lastState: NavigationProps) {
componentDidUpdate(lastState: PaginationNavigationProps) {
if (
this.props.page !== lastState.page &&
this.props.page <= this.props.lastPage &&
Expand Down Expand Up @@ -271,4 +271,4 @@ class Navigation extends Component<NavigationProps, NavigationState> {
}
}

export { Navigation };
export { PaginationNavigation };
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* This test was generated
*/
import { render } from '@testing-library/react';
import { Navigation } from '../../Navigation';
import { PaginationNavigation } from '../../PaginationNavigation';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('Navigation should match snapshot (auto-generated)', () => {
const { asFragment } = render(
<Navigation
<PaginationNavigation
className={"''"}
isDisabled={false}
isCompact={false}
Expand Down
Loading