From 18e70b4d73fa418801660abeb082932085e789f0 Mon Sep 17 00:00:00 2001 From: Vlada Gazizova <94864088+gazizova-vlada@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:08:53 +0300 Subject: [PATCH] Shared:ContextMenu:Fixed page crash when clicking on a table without a context menu button in the profile and importing data. --- .../context-menu/sub-components/SubMenu.tsx | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/shared/components/context-menu/sub-components/SubMenu.tsx b/packages/shared/components/context-menu/sub-components/SubMenu.tsx index fcbbbe005c..4a7f8d244d 100644 --- a/packages/shared/components/context-menu/sub-components/SubMenu.tsx +++ b/packages/shared/components/context-menu/sub-components/SubMenu.tsx @@ -516,32 +516,32 @@ const SubMenu = (props: { const active = isActive(); const submenuLower = renderSubMenuLower(); - const newModel = model.filter( - (item: ContextMenuModel) => item && !item.disabled, - ); - const rowHeights: number[] = newModel.map((item: ContextMenuModel) => { - if (!item) return 0; - if (item.isSeparator) return 13; - return 36; - }); + if (model.length) { + const newModel = model.filter( + (item: ContextMenuModel) => item && !item.disabled, + ); + const rowHeights: number[] = newModel.map((item: ContextMenuModel) => { + if (!item) return 0; + if (item.isSeparator) return 13; + return 36; + }); - const height = rowHeights.reduce((a, b) => a + b); - const viewport = DomHelpers.getViewport(); - const paddingList = 12; - const marginsList = 32; - const backdrop = 64; - const header = 55; + const height = rowHeights.reduce((a, b) => a + b); + const viewport = DomHelpers.getViewport(); + const paddingList = 12; + const marginsList = 32; + const backdrop = 64; + const header = 55; - const listHeight = - changeView && withHeader - ? height + paddingList + header > viewport.height - ? viewport.height - backdrop - header - paddingList - : height + paddingList - : height + paddingList + marginsList > viewport.height - ? viewport.height - marginsList - : height + paddingList; + const listHeight = + changeView && withHeader + ? height + paddingList + header > viewport.height + ? viewport.height - backdrop - header - paddingList + : height + paddingList + : height + paddingList + marginsList > viewport.height + ? viewport.height - marginsList + : height + paddingList; - if (model) { return (