Skip to content

Commit 8781f42

Browse files
authored
fix(Popups): prevent bubbling of internally used popover events (#618)
1 parent ff287cf commit 8781f42

File tree

9 files changed

+28
-7
lines changed

9 files changed

+28
-7
lines changed

packages/main/src/components/AnalyticalTable/AnalyticalTable.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ React.useEffect(() => {
234234
/>
235235
```
236236

237-
For more details on this behavior you can double check the [react-table docs](https://github.com/tannerlinsley/react-table/blob/master/docs/faq.md#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes).
237+
For more details on this behavior you can double check the [react-table docs](https://react-table.tanstack.com/docs/faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes).
238238

239239
### How can I show a subset of all columns on mobile devices?
240240

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderModal.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { PopoverHorizontalAlign } from '@ui5/webcomponents-react/lib/PopoverHori
2020
import { StandardListItem } from '@ui5/webcomponents-react/lib/StandardListItem';
2121
import React, { CSSProperties, forwardRef, RefObject, useCallback } from 'react';
2222
import { Ui5PopoverDomRef } from '../../../interfaces/Ui5PopoverDomRef';
23+
import { stopPropagation } from '../../../internal/stopPropagation';
2324
import { ColumnType } from '../types/ColumnType';
2425

2526
export interface ColumnHeaderModalProperties {
@@ -115,6 +116,7 @@ export const ColumnHeaderModal = forwardRef((props: ColumnHeaderModalProperties,
115116
placementType={PlacementType.Bottom}
116117
ref={ref}
117118
style={staticStyle as CSSProperties}
119+
onAfterClose={stopPropagation}
118120
>
119121
<List onItemClick={handleSort}>
120122
{isSortedAscending && (

packages/main/src/components/FilterBar/FilterDialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Text } from '@ui5/webcomponents-react/lib/Text';
2727
import { Title } from '@ui5/webcomponents-react/lib/Title';
2828
import { TitleLevel } from '@ui5/webcomponents-react/lib/TitleLevel';
2929
import React, { Children, cloneElement, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
30+
import { stopPropagation } from '../../internal/stopPropagation';
3031
import styles from './FilterBarDialog.jss';
3132
import { filterValue, renderSearchWithValue } from './utils';
3233

@@ -105,6 +106,7 @@ export const FilterDialog = (props) => {
105106

106107
const handleClose = useCallback(
107108
(e) => {
109+
stopPropagation(e);
108110
if (!showGoButton) {
109111
handleSave(e);
110112
return;
@@ -268,7 +270,7 @@ export const FilterDialog = (props) => {
268270
}, [renderChildren, toggledFilters, handleCheckBoxChange]);
269271

270272
return (
271-
<Dialog ref={dialogRef} onAfterClose={handleClose} header={renderHeader()} footer={renderFooter()}>
273+
<Dialog ref={dialogRef} header={renderHeader()} footer={renderFooter()} onAfterClose={handleClose}>
272274
<div className={classes.dialog}>
273275
{renderFBSearch && (
274276
<div className={classes.fbSearch} ref={searchRef}>

packages/main/src/components/MessageBox/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { TitleLevel } from '@ui5/webcomponents-react/lib/TitleLevel';
3737
import React, { FC, forwardRef, isValidElement, ReactNode, Ref, useCallback, useEffect, useMemo } from 'react';
3838
import { CommonProps } from '../../interfaces/CommonProps';
3939
import { Ui5DialogDomRef } from '../../interfaces/Ui5DialogDomRef';
40+
import { stopPropagation } from '../../internal/stopPropagation';
4041
import styles from './MessageBox.jss';
4142

4243
const actionTextMap = new Map();
@@ -154,6 +155,7 @@ const MessageBox: FC<MessageBoxPropTypes> = forwardRef((props: MessageBoxPropTyp
154155
const handleOnClose = useCallback(
155156
(e) => {
156157
const { action } = e.target.dataset;
158+
stopPropagation(e);
157159
onClose(enrichEventWithDetails(e, { action }));
158160
},
159161
[onClose]
@@ -180,7 +182,6 @@ const MessageBox: FC<MessageBoxPropTypes> = forwardRef((props: MessageBoxPropTyp
180182
style={style}
181183
tooltip={tooltip}
182184
className={className}
183-
onAfterClose={open ? handleOnClose : null}
184185
header={
185186
<header className={classes.header} data-type={type}>
186187
{iconToRender}
@@ -203,6 +204,7 @@ const MessageBox: FC<MessageBoxPropTypes> = forwardRef((props: MessageBoxPropTyp
203204
})}
204205
</footer>
205206
}
207+
onAfterClose={open ? handleOnClose : stopPropagation}
206208
{...passThroughProps}
207209
>
208210
<Text className={classes.content}>{children}</Text>

packages/main/src/components/ObjectPage/ObjectPageAnchorBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ToggleButton } from '@ui5/webcomponents-react/lib/ToggleButton';
1313
import React, { CSSProperties, forwardRef, ReactElement, RefObject, useCallback, useRef, useState } from 'react';
1414
import { createUseStyles } from 'react-jss';
1515
import { Ui5PopoverDomRef } from '../../interfaces/Ui5PopoverDomRef';
16+
import { stopPropagation } from '../../internal/stopPropagation';
1617
import { StandardListItem } from '../../webComponents/StandardListItem';
1718
import { ObjectPageAnchorButton } from './ObjectPageAnchorButton';
1819
import { safeGetChildrenArray } from './ObjectPageUtils';
@@ -194,7 +195,7 @@ const ObjectPageAnchorBar = forwardRef((props: Props, ref: RefObject<HTMLElement
194195
data-ui5wcr-object-page-header-action=""
195196
/>
196197
)}
197-
<Popover placementType={PlacementType.Bottom} noArrow ref={popoverRef}>
198+
<Popover placementType={PlacementType.Bottom} noArrow ref={popoverRef} onAfterClose={stopPropagation}>
198199
<List onItemClick={onSubSectionClick}>
199200
{popoverContent?.props?.children
200201
.filter((item) => item.props && item.props.isSubSection)

packages/main/src/components/SideNavigationListItem/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import React, {
2727
import { createPortal } from 'react-dom';
2828
import { createComponentStyles } from '@ui5/webcomponents-react-base/lib/createComponentStyles';
2929
import { CommonProps } from '../../interfaces/CommonProps';
30+
import { stopPropagation } from '../../internal/stopPropagation';
3031
import { sideNavigationListItemStyles } from './SideNavigationListItem.jss';
3132

3233
export interface SideNavigationListItemProps extends CommonProps {
@@ -158,7 +159,7 @@ const SideNavigationListItem: FC<SideNavigationListItemProps> = forwardRef(
158159
{displayedIcon}
159160
<div className={classes.condensedExpandTriangle} />
160161
{createPortal(
161-
<Popover ref={popoverRef} verticalAlign={PopoverVerticalAlign.Top}>
162+
<Popover ref={popoverRef} verticalAlign={PopoverVerticalAlign.Top} onAfterClose={stopPropagation}>
162163
<List onItemClick={props['onListItemSelected']}>
163164
<StandardListItem selected={isSelfSelected} data-id={id} tooltip={tooltip}>
164165
{text}

packages/main/src/components/Toolbar/OverflowPopover.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Popover } from '@ui5/webcomponents-react/lib/Popover';
66
import { ToggleButton } from '@ui5/webcomponents-react/lib/ToggleButton';
77
import React, { ReactElement, useCallback, useEffect, useRef, useState } from 'react';
88
import { createPortal } from 'react-dom';
9+
import { stopPropagation } from '../../internal/stopPropagation';
910

1011
export function OverflowPopover(props) {
1112
const { lastVisibleIndex, contentClass, children } = props;
@@ -31,7 +32,8 @@ export function OverflowPopover(props) {
3132
};
3233
}, []);
3334

34-
const handleClose = () => {
35+
const handleClose = (e) => {
36+
stopPropagation(e);
3537
setPressed(false);
3638
};
3739

packages/main/src/components/VariantManagement/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { TitleLevel } from '@ui5/webcomponents-react/lib/TitleLevel';
1919
import React, { FC, forwardRef, Ref, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2020
import { CommonProps } from '../../interfaces/CommonProps';
2121
import { Ui5ResponsivePopoverDomRef } from '../../interfaces/Ui5ResponsivePopoverDomRef';
22+
import { stopPropagation } from '../../internal/stopPropagation';
2223

2324
export interface VariantItem {
2425
key: string;
@@ -165,7 +166,13 @@ const VariantManagement: FC<VariantManagementPropTypes> = forwardRef(
165166
icon="navigation-down-arrow"
166167
disabled={disabled}
167168
/>
168-
<ResponsivePopover ref={popoverRef} headerText={popupTitle} placementType={placement} footer={footerButtons}>
169+
<ResponsivePopover
170+
ref={popoverRef}
171+
headerText={popupTitle}
172+
placementType={placement}
173+
footer={footerButtons}
174+
onAfterClose={stopPropagation}
175+
>
169176
<List onItemClick={handleVariantItemSelect} mode={ListMode.SingleSelect}>
170177
{variantItems.map((item) => (
171178
<StandardListItem
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const stopPropagation = (e) => {
2+
e.stopPropagation();
3+
e.stopImmediatePropagation();
4+
};

0 commit comments

Comments
 (0)