Skip to content
Open
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
6 changes: 4 additions & 2 deletions packages/react-core/src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ export interface PopoverProps {
showClose?: boolean;
/** Sets an interaction to open popover, defaults to "click" */
triggerAction?: 'click' | 'hover';
/** Whether to trap focus in the popover. */
/** Whether to trap focus in the popover. When using a triggerAction of "hover", this will be set to false
* by default and must remain false.
*/
Comment on lines +210 to +212

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Force hover-triggered popovers to disable focus trapping.

This only changes the default; an explicit withFocusTrap={true} still enables the trap for triggerAction="hover", contradicting the documented “must remain false” contract and the PR objective. Normalize the resolved value to false whenever triggerAction === 'hover', and add a regression test for the explicit-true case.

Proposed direction
-  withFocusTrap: propWithFocusTrap = triggerAction === 'hover' ? false : undefined,
+  withFocusTrap: propWithFocusTrap,
...
+  const resolvedWithFocusTrap = triggerAction === 'hover' ? false : propWithFocusTrap;
-  const [focusTrapActive, setFocusTrapActive] = useState(Boolean(propWithFocusTrap));
+  const [focusTrapActive, setFocusTrapActive] = useState(Boolean(resolvedWithFocusTrap));

Use resolvedWithFocusTrap for activation and returnFocusOnDeactivate as well.

Also applies to: 272-272

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react-core/src/components/Popover/Popover.tsx` around lines 210 -
212, Force the resolved focus-trap setting to false whenever triggerAction is
"hover", including when withFocusTrap is explicitly true. Update both activation
and return-focus behavior to use resolvedWithFocusTrap, and add a regression
test covering the explicit-true hover case.

withFocusTrap?: boolean;
/** The z-index of the popover. */
zIndex?: number;
Expand Down Expand Up @@ -267,7 +269,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
],
animationDuration = 300,
id,
withFocusTrap: propWithFocusTrap,
withFocusTrap: propWithFocusTrap = triggerAction === 'hover' ? false : undefined,
triggerRef,
hasNoPadding = false,
hasAutoWidth = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ By default, the `appendTo` prop of the popover will append to the document body

### Hoverable

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.

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

```
Expand Down
Loading