Skip to content

Commit

Permalink
"fix(Pagination): Fix bottom pagination layout" (#10315)
Browse files Browse the repository at this point in the history
* fix(Pgination): Fix bottom pagination layout

* fix(Pgination): Fix bottom pagination layout
  • Loading branch information
tlabaj authored May 3, 2024
1 parent 029351e commit 0ba7e5c
Show file tree
Hide file tree
Showing 4 changed files with 765 additions and 806 deletions.
2 changes: 2 additions & 0 deletions packages/react-core/src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
...props
}: PaginationProps) => {
const paginationRef = React.useRef<HTMLDivElement>(null);
const containerRef = React.useRef<HTMLDivElement>(null);

const getLastPage = () =>
// when itemCount is not known let's set lastPage as page+1 as we don't know the total count
Expand Down Expand Up @@ -335,6 +336,7 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
widgetId={`${widgetId}-${variant}`}
toggleTemplate={toggleTemplate}
isDisabled={isDisabled}
containerRef={containerRef}
/>
)}
<Navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface PaginationOptionsMenuProps extends React.HTMLProps<HTMLDivEleme
onPerPageSelect?: OnPerPageSelect;
/** Label for the English word "of". */
ofWord?: string;
containerRef?: React.RefObject<HTMLDivElement>;
}

export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMenuProps> = ({
Expand All @@ -74,12 +75,12 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
isLastFullPageShown = false,
itemsTitle = 'items',
toggleTemplate,
onPerPageSelect = () => null as any
onPerPageSelect = () => null as any,
containerRef
}: PaginationOptionsMenuProps) => {
const [isOpen, setIsOpen] = React.useState(false);
const toggleRef = React.useRef<HTMLButtonElement>(null);
const menuRef = React.useRef<HTMLDivElement>(null);
const containerRef = React.useRef<HTMLDivElement>(null);

const onToggle = () => {
setIsOpen((prevState) => !prevState);
Expand Down Expand Up @@ -208,18 +209,16 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
);

return (
<div ref={containerRef}>
<Popper
trigger={toggle}
triggerRef={toggleRef}
popper={menu}
popperRef={menuRef}
isVisible={isOpen}
direction={dropDirection}
appendTo={containerRef.current || undefined}
minWidth={minWidth !== undefined ? minWidth : 'revert'}
/>
</div>
<Popper
trigger={toggle}
triggerRef={toggleRef}
popper={menu}
popperRef={menuRef}
isVisible={isOpen}
direction={dropDirection}
appendTo={containerRef?.current || undefined}
minWidth={minWidth !== undefined ? minWidth : 'revert'}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,46 @@

exports[`PaginationOptionsMenu should match snapshot (auto-generated) 1`] = `
<DocumentFragment>
<div>
<button
aria-expanded="false"
aria-haspopup="listbox"
class="pf-v5-c-menu-toggle pf-m-plain pf-m-text"
id="''-toggle"
type="button"
<button
aria-expanded="false"
aria-haspopup="listbox"
class="pf-v5-c-menu-toggle pf-m-plain pf-m-text"
id="''-toggle"
type="button"
>
<span
class="pf-v5-c-menu-toggle__text"
>
<b>
0 - 0
</b>
Custom toggle template of
<b>
0
</b>
'items'
</span>
<span
class="pf-v5-c-menu-toggle__controls"
>
<span
class="pf-v5-c-menu-toggle__text"
>
<b>
0 - 0
</b>
Custom toggle template of
<b>
0
</b>
'items'
</span>
<span
class="pf-v5-c-menu-toggle__controls"
class="pf-v5-c-menu-toggle__toggle-icon"
>
<span
class="pf-v5-c-menu-toggle__toggle-icon"
<svg
aria-hidden="true"
class="pf-v5-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<svg
aria-hidden="true"
class="pf-v5-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
/>
</svg>
</span>
<path
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
/>
</svg>
</span>
</button>
</div>
</span>
</button>
</DocumentFragment>
`;
Loading

0 comments on commit 0ba7e5c

Please sign in to comment.