Skip to content

Commit 50090a3

Browse files
dbeaver/pro#7810 fix: improve submenu visibility handling for lazy-lo… (#3993)
* dbeaver/pro#7810 fix: improve submenu visibility handling for lazy-loaded items * dbeaver/pro#7810 fix: return back isDisabled for handler --------- Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
1 parent fc9b1d3 commit 50090a3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

webapp/packages/core-ui/src/ContextMenu/SubMenuElement.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ export const SubMenuElement = observer<ISubMenuElementProps>(function SubMenuEle
6868

6969
const handler = subMenuData.handler;
7070

71-
// TODO: it's better to remove this expensive check to allow lazy loading of menu items
72-
const hidden = getComputed(() => subMenuData.items.every(item => item.hidden) || handler?.isHidden?.(subMenuData.context));
71+
// NOTE: some menus rely on lazy loading. When items are not loaded yet `items` may be empty,
72+
// but the submenu still must be rendered to allow opening it and triggering loaders.
73+
const hidden = getComputed(() => {
74+
if (handler?.isHidden?.(subMenuData.context)) {
75+
return true;
76+
}
77+
78+
const hasVisibleItems = subMenuData.items.some(item => !item.hidden);
79+
const canLazyLoadItems = subMenuData.loaders.length > 0;
80+
81+
return !hasVisibleItems && !canLazyLoadItems;
82+
});
7383
const IconComponent = handler?.iconComponent?.() ?? subMenu.iconComponent?.();
7484
const extraProps = handler?.getExtraProps?.() ?? (subMenu.getExtraProps?.() as any);
7585
// TODO: fix, this triggers `Cannot update a component (`SubMenuElement`) while rendering a different component`

webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsBootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* CloudBeaver - Cloud Database Manager
3-
* Copyright (C) 2020-2024 DBeaver Corp and others
3+
* Copyright (C) 2020-2025 DBeaver Corp and others
44
*
55
* Licensed under the Apache License, Version 2.0.
66
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)