From ff72279f1ccd9952e05749dd925dc4ffd915fba8 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 11 Sep 2024 02:07:12 +0200 Subject: [PATCH] Composer / Embedded Message / Menu: Fix height --- src/components/middle/message/MessageContextMenu.tsx | 1 + src/hooks/useMenuPosition.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/middle/message/MessageContextMenu.tsx b/src/components/middle/message/MessageContextMenu.tsx index 3b36d010a..494635483 100644 --- a/src/components/middle/message/MessageContextMenu.tsx +++ b/src/components/middle/message/MessageContextMenu.tsx @@ -340,6 +340,7 @@ const MessageContextMenu: FC = ({ getRootElement={getRootElement} getMenuElement={getMenuElement} getLayout={getLayout} + withMaxHeight className={buildClassName( 'MessageContextMenu', 'fluid', withReactions && 'with-reactions', )} diff --git a/src/hooks/useMenuPosition.ts b/src/hooks/useMenuPosition.ts index 013edf4f2..661517145 100644 --- a/src/hooks/useMenuPosition.ts +++ b/src/hooks/useMenuPosition.ts @@ -23,6 +23,7 @@ interface DynamicPositionOptions { getRootElement: () => HTMLElement | null; getMenuElement: () => HTMLElement | null; getLayout?: () => Layout; + withMaxHeight?: boolean; } export type MenuPositionOptions = @@ -122,6 +123,7 @@ function processDynamically( getMenuElement, getTriggerElement, getLayout, + withMaxHeight, }: DynamicPositionOptions, ) { const triggerEl = getTriggerElement()!; @@ -214,10 +216,14 @@ function processDynamically( const transformOriginX = positionX === 'left' ? offsetX : menuRect.width + offsetX; const transformOriginY = positionY === 'bottom' ? menuRect.height + offsetY : offsetY; - const menuMaxHeight = rootRect.height - MENU_POSITION_BOTTOM_MARGIN - (marginTop || 0); - const bubbleStyle = `max-height: ${menuMaxHeight}px;`; const style = `left: ${left}px; top: ${top}px`; + let bubbleStyle; + if (withMaxHeight) { + const menuMaxHeight = rootRect.height - MENU_POSITION_BOTTOM_MARGIN - (marginTop || 0); + bubbleStyle = `max-height: ${menuMaxHeight}px;`; + } + return { positionX, positionY,