aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/design-system/src/components/DropdownToggler.tsx
diff options
context:
space:
mode:
authorstanislavh <stanislav.honcharov@sonarsource.com>2023-11-06 11:13:33 +0100
committersonartech <sonartech@sonarsource.com>2023-11-08 20:02:53 +0000
commit19c131bdfccb98c24bcf432c5e5968bc5d4ffd5c (patch)
tree459256e361a1f8a308e1d244737e11b979dab683 /server/sonar-web/design-system/src/components/DropdownToggler.tsx
parentc8d1b7eb2494d92f20fb8b498efdbb2e3f8ea12c (diff)
downloadsonarqube-19c131bdfccb98c24bcf432c5e5968bc5d4ffd5c.tar.gz
sonarqube-19c131bdfccb98c24bcf432c5e5968bc5d4ffd5c.zip
SONAR-20873 Create new education tour for accepting issues
Diffstat (limited to 'server/sonar-web/design-system/src/components/DropdownToggler.tsx')
-rw-r--r--server/sonar-web/design-system/src/components/DropdownToggler.tsx37
1 files changed, 24 insertions, 13 deletions
diff --git a/server/sonar-web/design-system/src/components/DropdownToggler.tsx b/server/sonar-web/design-system/src/components/DropdownToggler.tsx
index ee0f65e5733..15cabb5337a 100644
--- a/server/sonar-web/design-system/src/components/DropdownToggler.tsx
+++ b/server/sonar-web/design-system/src/components/DropdownToggler.tsx
@@ -27,24 +27,35 @@ type PopupProps = Popup['props'];
interface Props extends PopupProps {
onRequestClose: VoidFunction;
open: boolean;
+ withClickOutHandler?: boolean;
+ withFocusOutHandler?: boolean;
}
export function DropdownToggler(props: Props) {
- const { children, open, onRequestClose, overlay, ...popupProps } = props;
+ const {
+ children,
+ open,
+ onRequestClose,
+ withClickOutHandler = true,
+ withFocusOutHandler = true,
+ overlay,
+ ...popupProps
+ } = props;
+
+ let finalOverlay = <EscKeydownHandler onKeydown={onRequestClose}>{overlay}</EscKeydownHandler>;
+
+ if (withFocusOutHandler) {
+ finalOverlay = <FocusOutHandler onFocusOut={onRequestClose}>{finalOverlay}</FocusOutHandler>;
+ }
+
+ if (withClickOutHandler) {
+ finalOverlay = (
+ <OutsideClickHandler onClickOutside={onRequestClose}>{finalOverlay}</OutsideClickHandler>
+ );
+ }
return (
- <Popup
- overlay={
- open ? (
- <OutsideClickHandler onClickOutside={onRequestClose}>
- <FocusOutHandler onFocusOut={onRequestClose}>
- <EscKeydownHandler onKeydown={onRequestClose}>{overlay}</EscKeydownHandler>
- </FocusOutHandler>
- </OutsideClickHandler>
- ) : undefined
- }
- {...popupProps}
- >
+ <Popup overlay={open && finalOverlay} {...popupProps}>
{children}
</Popup>
);