From 143555bbd8ddca1812d77c5a870ec33c6f65a625 Mon Sep 17 00:00:00 2001 From: martincupela Date: Thu, 5 Sep 2024 12:38:38 +0200 Subject: [PATCH] feat: use own anchor root for DialogAnchor --- src/components/Dialog/DialogAnchor.tsx | 8 +- src/components/Dialog/DialogPortal.tsx | 27 ++- .../MessageActions/MessageActions.tsx | 5 +- .../MessageActions/MessageActionsBox.tsx | 163 ++++++++++-------- 4 files changed, 109 insertions(+), 94 deletions(-) diff --git a/src/components/Dialog/DialogAnchor.tsx b/src/components/Dialog/DialogAnchor.tsx index 31e62dcec..20c7434f0 100644 --- a/src/components/Dialog/DialogAnchor.tsx +++ b/src/components/Dialog/DialogAnchor.tsx @@ -1,3 +1,4 @@ +import clsx from 'clsx'; import { Placement } from '@popperjs/core'; import React, { ComponentProps, PropsWithChildren, useEffect, useRef } from 'react'; import { usePopper } from 'react-popper'; @@ -48,7 +49,7 @@ export function useDialogAnchor({ type DialogAnchorProps = PropsWithChildren> & { id: string; -} & ComponentProps<'div' | 'span'>; +} & ComponentProps<'div'>; export const DialogAnchor = ({ children, @@ -56,6 +57,7 @@ export const DialogAnchor = ({ id, placement = 'auto', referenceElement = null, + ...restDivProps }: DialogAnchorProps) => { const open = useDialogIsOpen(id); const { attributes, popperElementRef, styles } = useDialogAnchor({ @@ -67,8 +69,10 @@ export const DialogAnchor = ({ return (
diff --git a/src/components/Dialog/DialogPortal.tsx b/src/components/Dialog/DialogPortal.tsx index 9110b42e5..e31a3582f 100644 --- a/src/components/Dialog/DialogPortal.tsx +++ b/src/components/Dialog/DialogPortal.tsx @@ -18,22 +18,17 @@ export const DialogPortalDestination = () => { ); return ( - <> -
dialogsManager.closeAll()} - style={{ - height: '100%', - inset: '0', - overflow: 'hidden', - position: 'absolute', - width: '100%', - zIndex: shouldRender ? '2' : '-1', - }} - > -
-
- +
dialogsManager.closeAll()} + style={ + { + '--str-chat__dialog-overlay-height': shouldRender ? '100%' : '0', + } as React.CSSProperties + } + >
); }; diff --git a/src/components/MessageActions/MessageActions.tsx b/src/components/MessageActions/MessageActions.tsx index 9860f9b7d..41dd364e7 100644 --- a/src/components/MessageActions/MessageActions.tsx +++ b/src/components/MessageActions/MessageActions.tsx @@ -146,9 +146,6 @@ export const MessageActions = < toggleOpen={dialog?.toggleSingle} > - )} - {messageActions.indexOf(MESSAGE_ACTIONS.pin) > -1 && !message.parent_id && ( - - )} - {messageActions.indexOf(MESSAGE_ACTIONS.markUnread) > -1 && !threadList && !!message.id && ( - - )} - {messageActions.indexOf(MESSAGE_ACTIONS.flag) > -1 && ( - - )} - {messageActions.indexOf(MESSAGE_ACTIONS.mute) > -1 && ( - - )} - {messageActions.indexOf(MESSAGE_ACTIONS.edit) > -1 && ( - - )} - {messageActions.indexOf(MESSAGE_ACTIONS.delete) > -1 && ( - - )} +
+
+ + {messageActions.indexOf(MESSAGE_ACTIONS.quote) > -1 && ( + + )} + {messageActions.indexOf(MESSAGE_ACTIONS.pin) > -1 && !message.parent_id && ( + + )} + {messageActions.indexOf(MESSAGE_ACTIONS.markUnread) > -1 && !threadList && !!message.id && ( + + )} + {messageActions.indexOf(MESSAGE_ACTIONS.flag) > -1 && ( + + )} + {messageActions.indexOf(MESSAGE_ACTIONS.mute) > -1 && ( + + )} + {messageActions.indexOf(MESSAGE_ACTIONS.edit) > -1 && ( + + )} + {messageActions.indexOf(MESSAGE_ACTIONS.delete) > -1 && ( + + )} +
); };