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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { ApplicationLauncherContext } from './ApplicationLauncherContext';
import { ToggleMenuBaseProps } from '../../helpers/Popper/Popper';
import { createRenderableFavorites, extendItemsWithFavorite } from '../../helpers/favorites';

export interface ApplicationLauncherProps extends ToggleMenuBaseProps, React.HTMLProps<HTMLDivElement> {
export interface ApplicationLauncherProps
extends Omit<ToggleMenuBaseProps, 'menuAppendTo'>,
React.HTMLProps<HTMLDivElement> {
/** Additional element css classes */
className?: string;
/** Display menu above or below dropdown toggle */
Expand All @@ -35,6 +37,14 @@ export interface ApplicationLauncherProps extends ToggleMenuBaseProps, React.HTM
isGrouped?: boolean;
/** Toggle Icon, optional to override the icon used for the toggle */
toggleIcon?: React.ReactNode;
/** The container to append the menu to. Defaults to 'inline'.
* If your menu is being cut off you can append it to an element higher up the DOM tree.
* Some examples:
* menuAppendTo="parent"
* menuAppendTo={() => document.body}
* menuAppendTo={document.getElementById('target')}
*/
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
/** ID list of favorited ApplicationLauncherItems */
favorites?: string[];
/** Enables favorites. Callback called when an ApplicationLauncherItem's favorite button is clicked */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getOUIAProps, OUIAProps, getDefaultOUIAId } from '../../helpers';
let currentId = 0;
const newId = currentId++;

export interface ContextSelectorProps extends ToggleMenuBaseProps, OUIAProps {
export interface ContextSelectorProps extends Omit<ToggleMenuBaseProps, 'menuAppendTo'>, OUIAProps {
/** content rendered inside the Context Selector */
children?: React.ReactNode;
/** Classes applied to root element of Context Selector */
Expand All @@ -29,6 +29,14 @@ export interface ContextSelectorProps extends ToggleMenuBaseProps, OUIAProps {
onToggle?: (event: any, value: boolean) => void;
/** Function callback called when user selects item */
onSelect?: (event: any, value: React.ReactNode) => void;
/** The container to append the menu to. Defaults to 'inline'.
* If your menu is being cut off you can append it to an element higher up the DOM tree.
* Some examples:
* menuAppendTo="parent"
* menuAppendTo={() => document.body}
* menuAppendTo={document.getElementById('target')}
*/
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
/** Flag indicating that the context selector should expand to full height */
isFullHeight?: boolean;
/** Labels the Context Selector for Screen Readers */
Expand Down
16 changes: 14 additions & 2 deletions packages/react-core/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { DropdownWithContext } from './DropdownWithContext';
import { ToggleMenuBaseProps } from '../../helpers/Popper/Popper';
import { OUIAProps, useOUIAId } from '../../helpers';

export interface DropdownProps extends ToggleMenuBaseProps, React.HTMLProps<HTMLDivElement>, OUIAProps {
export interface DropdownProps
extends Omit<ToggleMenuBaseProps, 'menuAppendTo'>,
React.HTMLProps<HTMLDivElement>,
OUIAProps {
/** Anything which can be rendered in a dropdown */
children?: React.ReactNode;
/** Classes applied to root element of dropdown */
Expand All @@ -32,6 +35,14 @@ export interface DropdownProps extends ToggleMenuBaseProps, React.HTMLProps<HTML
};
/** Display menu above or below dropdown toggle */
direction?: DropdownDirection | 'up' | 'down';
/** The container to append the menu to. Defaults to 'inline'.
* If your menu is being cut off you can append it to an element higher up the DOM tree.
* Some examples:
* menuAppendTo="parent"
* menuAppendTo={() => document.body}
* menuAppendTo={document.getElementById('target')}
*/
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
/** Flag to indicate if dropdown has groups */
isGrouped?: boolean;
/** Toggle for the dropdown, examples: <DropdownToggle> or <DropdownToggleCheckbox> */
Expand All @@ -54,6 +65,7 @@ export const Dropdown: React.FunctionComponent<DropdownProps> = ({
ouiaSafe,
alignments,
contextProps,
menuAppendTo = 'inline',
...props
}: DropdownProps) => (
<DropdownContext.Provider
Expand All @@ -79,7 +91,7 @@ export const Dropdown: React.FunctionComponent<DropdownProps> = ({
...contextProps
}}
>
<DropdownWithContext {...props} />
<DropdownWithContext menuAppendTo={menuAppendTo} {...props} />
</DropdownContext.Provider>
);
Dropdown.displayName = 'Dropdown';
13 changes: 12 additions & 1 deletion packages/react-core/src/components/OptionsMenu/OptionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export enum OptionsMenuDirection {
down = 'down'
}

export interface OptionsMenuProps extends ToggleMenuBaseProps, React.HTMLProps<HTMLDivElement>, OUIAProps {
export interface OptionsMenuProps
extends Omit<ToggleMenuBaseProps, 'menuAppendTo'>,
React.HTMLProps<HTMLDivElement>,
OUIAProps {
/** Classes applied to root element of the options menu */
className?: string;
/** Id of the root element of the options menu */
Expand All @@ -36,6 +39,14 @@ export interface OptionsMenuProps extends ToggleMenuBaseProps, React.HTMLProps<H
position?: 'right' | 'left';
/** Menu will open up or open down from the options menu toggle */
direction?: 'up' | 'down';
/** The container to append the menu to. Defaults to 'inline'.
* If your menu is being cut off you can append it to an element higher up the DOM tree.
* Some examples:
* menuAppendTo="parent"
* menuAppendTo={() => document.body}
* menuAppendTo={document.getElementById('target')}
*/
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
}

export const OptionsMenu: React.FunctionComponent<OptionsMenuProps> = ({
Expand Down
10 changes: 9 additions & 1 deletion packages/react-core/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface SelectViewMoreObject {
onClick: (event: React.MouseEvent | React.ChangeEvent) => void;
}
export interface SelectProps
extends ToggleMenuBaseProps,
extends Omit<ToggleMenuBaseProps, 'menuAppendTo'>,
Omit<React.HTMLProps<HTMLDivElement>, 'onSelect' | 'ref' | 'checked' | 'selected'>,
OUIAProps {
/** Content rendered inside the Select. Must be React.ReactElement<SelectGroupProps>[] */
Expand Down Expand Up @@ -165,6 +165,14 @@ export interface SelectProps
shouldResetOnSelect?: boolean;
/** Content rendered in the footer of the select menu */
footer?: React.ReactNode;
/** The container to append the menu to. Defaults to 'inline'.
* If your menu is being cut off you can append it to an element higher up the DOM tree.
* Some examples:
* menuAppendTo="parent"
* menuAppendTo={() => document.body}
* menuAppendTo={document.getElementById('target')}
*/
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
}

export interface SelectState {
Expand Down
1 change: 1 addition & 0 deletions packages/react-core/src/helpers/Popper/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const getOppositePlacement = (placement: Placement): any =>
(matched: string) => hash[matched as 'left' | 'right' | 'bottom' | 'top'] as BasePlacement
);

/** @deprecated Please use the menuAppendTo prop directly from within the PF component which uses it. */
export interface ToggleMenuBaseProps {
/** The container to append the menu to. Defaults to 'inline'
* If your menu is being cut off you can append it to an element higher up the DOM tree.
Expand Down