From d346ddf77fb624d69228a0fe89ff570a5b44ba66 Mon Sep 17 00:00:00 2001 From: 7PH Date: Thu, 4 May 2023 18:15:43 +0200 Subject: [PATCH] SONAR-19019 Fix all dropdown menus not closing after a click --- .../main/js/components/controls/Dropdown.tsx | 3 ++ .../src/main/js/components/ui/popups.tsx | 37 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx index ac1e5132b17..5c45f98ec7c 100644 --- a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx +++ b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx @@ -97,6 +97,7 @@ export default class Dropdown extends React.PureComponent { {this.props.overlay} @@ -119,6 +120,7 @@ interface OverlayProps { children: React.ReactNode; noPadding?: boolean; placement?: PopupPlacement; + useEventBoundary?: boolean; } export class DropdownOverlay extends React.Component { @@ -141,6 +143,7 @@ export class DropdownOverlay extends React.Component { ? { marginLeft: `calc(50% + ${leftFix}px)` } : undefined } + useEventBoundary={this.props.useEventBoundary} > {this.props.children} diff --git a/server/sonar-web/src/main/js/components/ui/popups.tsx b/server/sonar-web/src/main/js/components/ui/popups.tsx index 8bbef2aeee3..55580b338c4 100644 --- a/server/sonar-web/src/main/js/components/ui/popups.tsx +++ b/server/sonar-web/src/main/js/components/ui/popups.tsx @@ -55,27 +55,30 @@ interface PopupProps { noPadding?: boolean; placement?: PopupPlacement; style?: React.CSSProperties; + useEventBoundary?: boolean; } function PopupBase(props: PopupProps, ref: React.Ref) { - const { noArrow = false, placement = PopupPlacement.Bottom } = props; - return ( - -
- {props.children} - {!noArrow && } -
-
+ const { useEventBoundary = true, noArrow = false, placement = PopupPlacement.Bottom } = props; + const inner = ( +
+ {props.children} + {!noArrow && } +
); + if (useEventBoundary) { + return {inner}; + } + return inner; } const PopupWithRef = React.forwardRef(PopupBase); -- 2.39.5