Skip to content

Commit 9add887

Browse files
fix(navbar): extract popup offset into shared constant
1 parent c0ceef7 commit 9add887

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

superset-frontend/src/features/home/Menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
MenuData,
3434
} from 'src/types/bootstrapTypes';
3535
import RightMenu from './RightMenu';
36+
import { NAVBAR_MENU_POPUP_OFFSET } from './commonMenuData';
3637

3738
interface MenuProps {
3839
data: MenuData;
@@ -277,7 +278,7 @@ export function Menu({
277278
key: label,
278279
label,
279280
icon: <Icons.DownOutlined iconSize="xs" />,
280-
popupOffset: [0, -8],
281+
popupOffset: NAVBAR_MENU_POPUP_OFFSET,
281282
children: childItems,
282283
};
283284
};

superset-frontend/src/features/home/RightMenu.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
GlobalMenuDataOptions,
5454
RightMenuProps,
5555
} from './types';
56+
import { NAVBAR_MENU_POPUP_OFFSET } from './commonMenuData';
5657

5758
const extensionsRegistry = getExtensionsRegistry();
5859

@@ -379,7 +380,7 @@ const RightMenu = ({
379380
label: menu.label,
380381
icon: menu.icon,
381382
children: childItems,
382-
popupOffset: [0, -8],
383+
popupOffset: NAVBAR_MENU_POPUP_OFFSET,
383384
});
384385
} else if (menu.url) {
385386
if (
@@ -560,7 +561,7 @@ const RightMenu = ({
560561
className: 'submenu-with-caret',
561562
icon: <Icons.DownOutlined iconSize="xs" />,
562563
children: buildNewDropdownItems(),
563-
popupOffset: [0, -8],
564+
popupOffset: NAVBAR_MENU_POPUP_OFFSET,
564565
});
565566
}
566567

@@ -578,7 +579,7 @@ const RightMenu = ({
578579
icon: <Icons.DownOutlined iconSize="xs" />,
579580
children: buildSettingsMenuItems(),
580581
className: 'submenu-with-caret',
581-
popupOffset: [0, -8],
582+
popupOffset: NAVBAR_MENU_POPUP_OFFSET,
582583
});
583584

584585
return items;

superset-frontend/src/features/home/commonMenuData.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
*/
1919
import { t } from '@superset-ui/core';
2020

21+
/**
22+
* Shared popup offset configuration for navbar menu dropdowns.
23+
*/
24+
export const NAVBAR_MENU_POPUP_OFFSET: [number, number] = [0, -8];
25+
2126
export const commonMenuData = {
2227
name: t('SQL'),
2328
tabs: [

superset-frontend/src/hooks/useThemeMenuItems.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Icons, Tooltip } from '@superset-ui/core/components';
2121
import type { MenuItem } from '@superset-ui/core/components/Menu';
2222
import { t } from '@superset-ui/core';
2323
import { ThemeMode, ThemeAlgorithm } from '@apache-superset/core/ui';
24+
import { NAVBAR_MENU_POPUP_OFFSET } from 'src/features/home/commonMenuData';
2425

2526
export interface ThemeSubMenuOption {
2627
key: ThemeMode;
@@ -138,6 +139,6 @@ export const useThemeMenuItems = ({
138139
icon: <Icons.DownOutlined iconSize="xs" />,
139140
className: 'submenu-with-caret',
140141
children,
141-
popupOffset: [0, -8],
142+
popupOffset: NAVBAR_MENU_POPUP_OFFSET,
142143
};
143144
};

0 commit comments

Comments
 (0)