Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(popper): improve flip behavior in RTL #9640

Merged
merged 4 commits into from
Oct 27, 2023
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
2 changes: 2 additions & 0 deletions packages/react-core/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface DropdownPopperProps {
enableFlip?: boolean;
/** The container to append the popper to. Defaults to 'inline'. */
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
/** Flag to prevent the popper from overflowing its container and becoming partially obscured. */
preventOverflow?: boolean;
}

export interface DropdownToggleProps {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-core/src/components/Menu/MenuContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface MenuPopperProps {
maxWidth?: string | 'trigger';
/** Enable to flip the popper when it reaches the boundary */
enableFlip?: boolean;
/** Flag to prevent the popper from overflowing its container and becoming partially obscured. */
preventOverflow?: boolean;
}
export interface MenuContainerProps {
/** Menu to be rendered */
Expand Down
2 changes: 2 additions & 0 deletions packages/react-core/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface SelectPopperProps {
* appendTo={document.getElementById('target')}
*/
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
/** Flag to prevent the popper from overflowing its container and becoming partially obscured. */
preventOverflow?: boolean;
}

export interface SelectToggleProps {
Expand Down
7 changes: 5 additions & 2 deletions packages/react-core/src/helpers/Popper/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export interface PopperProps {
* Lifecycle function invoked when the popper has fully transitioned in.
*/
onShown?: () => void;
/** Flag to prevent the popper from overflowing its container and becoming partially obscured. */
preventOverflow?: boolean;
}

export const Popper: React.FunctionComponent<PopperProps> = ({
Expand Down Expand Up @@ -224,7 +226,8 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
onHide = () => {},
onMount = () => {},
onShow = () => {},
onShown = () => {}
onShown = () => {},
preventOverflow = false
}) => {
const [triggerElement, setTriggerElement] = React.useState(null);
const [refElement, setRefElement] = React.useState<HTMLElement>(null);
Expand Down Expand Up @@ -436,7 +439,7 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
},
{
name: 'preventOverflow',
enabled: false
enabled: preventOverflow
},
{
// adds attribute [data-popper-reference-hidden] to the popper element which can be used to hide it using CSS
Expand Down
Loading