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
11 changes: 11 additions & 0 deletions packages/react-core/src/components/Popover/examples/Popover.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';

## Examples

By default, the `appendTo` prop of the popover will append it to the parent element. However, in some cases, the popover might be too big for the parent and not fully visible. To solve this issue, users have two options:

1. Add the prop `appendTo={() => document.body}` to append the popover to the document body instead of the parent element.
2. Increase the z-index of the parent element to be higher than the z-index of the element that is hiding the popover.

### Basic

```ts file="./PopoverBasic.tsx"
Expand All @@ -38,6 +43,8 @@ Note: If you use the isVisible prop, either refer to the example above or if you

### Width auto

Here the popover goes over the navigation, so the prop `appendTo` is set to the documents body.

```ts file="./PopoverWidthAuto.tsx"
```

Expand All @@ -58,10 +65,14 @@ Note: If you use the isVisible prop, either refer to the example above or if you

### Popover with icon in the title

Here the popover goes over the navigation, so the prop `appendTo` is set to the documents body.

```ts file="./PopoverWithIconInTheTitle.tsx"
```

### Alert popover

Here the popover goes over the navigation, so the prop `appendTo` is set to the documents body.

```ts file="./PopoverAlert.tsx"
```
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const AlertPopover: React.FunctionComponent = () => {
headerComponent="h1"
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
footerContent="Popover footer"
appendTo={() => document.body}
>
<Button>Toggle popover</Button>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const PopoverWidthAuto: React.FunctionComponent = () => (
aria-label="Popover with auto-width"
hasAutoWidth
bodyContent={() => <div>Removes fixed-width and allows width to be defined by contents</div>}
appendTo={() => document.body}
>
<Button>Toggle popover</Button>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const PopoverWithIconInTheTitle: React.FunctionComponent = () => (
headerIcon={<BullhornIcon />}
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
footerContent="Popover footer"
appendTo={() => document.body}
>
<Button>Toggle popover</Button>
</Popover>
Expand Down