', async ({mount, expectScreenshot}) => {
await mount(, undefined, {
width: 1200,
diff --git a/src/components/AsideHeader/types.tsx b/src/components/AsideHeader/types.tsx
index b0c31439..35255df8 100644
--- a/src/components/AsideHeader/types.tsx
+++ b/src/components/AsideHeader/types.tsx
@@ -1,3 +1,5 @@
+import * as React from 'react';
+
import {QAProps} from '@gravity-ui/uikit';
import {RenderContentType} from '../Content';
diff --git a/src/components/TopAlert/TopAlert.tsx b/src/components/TopAlert/TopAlert.tsx
index 7538adf7..3ce027b4 100644
--- a/src/components/TopAlert/TopAlert.tsx
+++ b/src/components/TopAlert/TopAlert.tsx
@@ -24,7 +24,10 @@ export const TopAlert = ({alert, className, mobileView = false}: Props) => {
const handleClose = React.useCallback(() => {
setOpened(false);
- alert?.onCloseTopAlert?.();
+
+ if (alert && 'onCloseTopAlert' in alert) {
+ alert.onCloseTopAlert?.();
+ }
}, [alert]);
React.useEffect(() => {
@@ -33,10 +36,23 @@ export const TopAlert = ({alert, className, mobileView = false}: Props) => {
}
}, [opened, updateTopSize]);
- if (!alert || !alert.message) {
+ if (!alert) {
return null;
}
+ const {render} = alert;
+
+ if (typeof render === 'function') {
+ return (
+
+ {opened && render({handleClose})}
+
+ );
+ }
+
return (
void;
+ render?: never;
}
+
+export type TopAlertProps =
+ | TopAlertBaseProps
+ | {
+ render: (params: {handleClose: () => void}) => React.ReactElement;
+ };