Skip to content

Commit e86fa5d

Browse files
fix(Popover): fixed focus trapped on hoverable trigger (#12591)
* fix(Popover): fixed focus trapped on hoverable trigger * Added deprecation to hoverable
1 parent c4086a0 commit e86fa5d

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/react-core/src/components/Popover/Popover.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,11 @@ export interface PopoverProps {
205205
shouldOpen?: (event: MouseEvent | KeyboardEvent, showFunction?: () => void) => void;
206206
/** Flag indicating whether the close button should be shown. */
207207
showClose?: boolean;
208-
/** Sets an interaction to open popover, defaults to "click" */
208+
/** @deprecated Sets an interaction to open popover, defaults to "click" */
209209
triggerAction?: 'click' | 'hover';
210-
/** Whether to trap focus in the popover. */
210+
/** Whether to trap focus in the popover. When using a triggerAction of "hover", this will be set to false
211+
* by default and must remain false.
212+
*/
211213
withFocusTrap?: boolean;
212214
/** The z-index of the popover. */
213215
zIndex?: number;
@@ -267,7 +269,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
267269
],
268270
animationDuration = 300,
269271
id,
270-
withFocusTrap: propWithFocusTrap,
272+
withFocusTrap: propWithFocusTrap = triggerAction === 'hover' ? false : undefined,
271273
triggerRef,
272274
hasNoPadding = false,
273275
hasAutoWidth = false,

packages/react-core/src/components/Popover/examples/Popover.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ By default, the `appendTo` prop of the popover will append to the document body
2525

2626
### Hoverable
2727

28-
```ts file="./PopoverHover.tsx"
28+
Pass the `triggerAction="hover"` property to make a `<Popover>` that is triggered via hover and focus rather than on click. When using a hoverable Popover, you **must not** include any interactive or semantic content (e.g. buttons, links, headings, lists, etc), as focus is not intended to enter a hoverable `<Popover>`. Including such content may cause an inaccessible UI for users who are not able to reach the content when navigating via assistive tech.
29+
30+
It is instead recommended to use our [tooltip component](/components/tooltip).
31+
32+
```ts isDeprecated file="./PopoverHover.tsx"
2933

3034
```
3135

0 commit comments

Comments
 (0)