Skip to content

Commit a1d12a7

Browse files
committed
use DecoupledOverlay for the notification
1 parent 6612baf commit a1d12a7

1 file changed

Lines changed: 33 additions & 28 deletions

File tree

src/cmem/ActivityControl/ActivityControlWidget.tsx

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {CLASSPREFIX as eccgui} from "../../configuration/constants";
1010
import {
1111
Card,
1212
ContextMenu,
13-
ContextOverlay,
13+
DecoupledOverlay,
1414
IconButton,
1515
MenuItem,
1616
Notification,
@@ -223,34 +223,39 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
223223
>
224224
{activityActions &&
225225
activityActions.map((action, idx) => {
226-
const ActionButton = () => <IconButton
227-
data-test-id={action["data-test-id"]}
228-
data-testid={action["data-testid"]}
229-
name={action.icon}
230-
text={action.tooltip}
231-
onClick={action.action}
232-
disabled={action.disabled}
233-
intent={action.hasStateWarning ? "warning" : undefined}
234-
tooltipProps={{
235-
hoverOpenDelay: 200,
236-
placement: "bottom"
237-
}}
238-
active={action.active}
239-
/>
226+
const actionButtonRef = React.useRef(null);
227+
const ActionButton = () => (
228+
<IconButton
229+
data-test-id={action["data-test-id"]}
230+
data-testid={action["data-testid"]}
231+
name={action.icon}
232+
text={action.tooltip}
233+
onClick={action.action}
234+
disabled={action.disabled}
235+
intent={action.hasStateWarning ? "warning" : undefined}
236+
tooltipProps={{
237+
hoverOpenDelay: 200,
238+
placement: "bottom"
239+
}}
240+
active={action.active}
241+
/>
242+
)
240243
return action.notification ?
241-
<ContextOverlay
242-
key={idx}
243-
content={<Notification
244-
message={action.notification.message}
245-
intent={action.notification.intent ?? "neutral"}
246-
onDismiss={action.notification.onClose}
247-
timeout={action.notification.timeout}
248-
/>}
249-
defaultIsOpen={true}
250-
onClose={action.notification.onClose}
251-
>
252-
<ActionButton />
253-
</ContextOverlay> :
244+
<>
245+
<span key={idx} ref={actionButtonRef}>
246+
<ActionButton />
247+
</span>
248+
{actionButtonRef.current && (
249+
<DecoupledOverlay targetSelectorOrElement={actionButtonRef.current} paddingSize={"small"}>
250+
<Notification
251+
message={action.notification.message}
252+
intent={action.notification.intent ?? "neutral"}
253+
onDismiss={action.notification.onClose}
254+
timeout={action.notification.timeout}
255+
/>
256+
</DecoupledOverlay>
257+
)}
258+
</> :
254259
<ActionButton key={idx} />
255260
})}
256261
{additionalActions}

0 commit comments

Comments
 (0)