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: 4 additions & 0 deletions packages/react-core/src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export interface PaginationProps extends React.HTMLProps<HTMLDivElement>, OUIAPr
ouiaId?: number | string;
/** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
ouiaSafe?: boolean;
/** @beta The container to append the pagination options menu to. */
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline';
}

const handleInputWidth = (lastPage: number, node: HTMLDivElement) => {
Expand Down Expand Up @@ -229,6 +231,7 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
ouiaSafe = true,
usePageInsets,
inset,
menuAppendTo,
...props
}: PaginationProps) => {
const paginationRef = React.useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -337,6 +340,7 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
toggleTemplate={toggleTemplate}
isDisabled={isDisabled}
containerRef={containerRef}
appendTo={menuAppendTo}
/>
)}
<Navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export interface PaginationOptionsMenuProps extends React.HTMLProps<HTMLDivEleme
onPerPageSelect?: OnPerPageSelect;
/** Label for the English word "of". */
ofWord?: string;
/** React ref for the container to append the options menu to. This is a static ref provided by the main pagination component. */
containerRef?: React.RefObject<HTMLDivElement>;
/** @beta The container to append the pagination options menu to. Overrides the containerRef prop. */
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
}

export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMenuProps> = ({
Expand All @@ -76,7 +79,8 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
itemsTitle = '',
toggleTemplate,
onPerPageSelect = () => null as any,
containerRef
containerRef,
appendTo
}: PaginationOptionsMenuProps) => {
const [isOpen, setIsOpen] = React.useState(false);
const toggleRef = React.useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -208,6 +212,7 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
</Menu>
);

const containerToAppendTo = appendTo ?? (containerRef?.current || undefined);
return (
<Popper
trigger={toggle}
Expand All @@ -216,7 +221,7 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
popperRef={menuRef}
isVisible={isOpen}
direction={dropDirection}
appendTo={containerRef?.current || undefined}
appendTo={containerToAppendTo}
minWidth={minWidth !== undefined ? minWidth : 'revert'}
/>
);
Expand Down