Skip to content

Commit

Permalink
(AIR-59161):fix for loosing focus of menu after selecting menuitem (#…
Browse files Browse the repository at this point in the history
…1428)

* (AIR-59161):fix for loosing focus of menu after selecting menuitem

* (AIR-59161):changelog

* (AIR-59161):changelog type change from patch to minor
  • Loading branch information
takhila499 authored Dec 14, 2023
1 parent e5595b5 commit 96c7542
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "pcln-menu",
"comment": "Adding querySelectorPortal prop to menu item to fix the focus issue.",
"type": "minor"
}
],
"packageName": "pcln-menu"
}
34 changes: 21 additions & 13 deletions packages/menu/src/Menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function Menu({
trapFocus,
placement,
children,
querySelectorPortal,
...props
}) {
const MenuContent = ({ handleClose }) => (
Expand Down Expand Up @@ -57,19 +58,25 @@ function Menu({
)

return (
<Popover
aria-controls={id}
hideArrow
idx={id}
placement={placement ?? 'bottom-start'}
renderContent={MenuContent}
trapFocus={trapFocus}
width={width}
zIndex={1600}
{...props}
>
<ClickableNode />
</Popover>
<>
<Popover
aria-controls={id}
hideArrow
idx={id}
placement={placement ?? 'bottom-start'}
renderContent={MenuContent}
trapFocus={trapFocus}
width={width}
zIndex={1600}
querySelectorPortal={`.${querySelectorPortal}`}
{...props}
>
<ClickableNode />
</Popover>
{querySelectorPortal ? (
<div style={{ width: 0, display: 'inline-block' }} className={querySelectorPortal} />
) : null}
</>
)
}

Expand All @@ -87,6 +94,7 @@ Menu.propTypes = {
trapFocus: PropTypes.bool,
placement: PropTypes.string,
children: PropTypes.node,
querySelectorPortal: PropTypes.string,
}

Menu.defaultProps = {
Expand Down

0 comments on commit 96c7542

Please sign in to comment.