Skip to content

Commit 86eabb9

Browse files
authored
Fix gap token on MenuList (#3945)
* Fix gap tokens on MenuList * Change files * remove console
1 parent e3520e6 commit 86eabb9

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix gap tokens on MenuList",
4+
"packageName": "@fluentui-react-native/menu",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/components/Menu/src/MenuList/MenuList.styling.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@ export const stylingSettings: UseStylingOptions<MenuListProps, MenuListSlotProps
1919
style: {
2020
backgroundColor: tokens.backgroundColor,
2121
display: 'flex',
22+
gap: tokens.gap,
2223
...layoutStyles.from(tokens, theme),
2324
...(Platform.OS === 'android' && { borderRadius: tokens.borderRadius }),
2425
},
25-
gap: tokens.gap,
2626
}),
27-
['backgroundColor', 'gap', ...layoutStyles.keys],
27+
['backgroundColor', 'borderRadius', 'gap', ...layoutStyles.keys],
28+
),
29+
focusZone: buildProps(
30+
(tokens: MenuListTokens) => ({
31+
style: {
32+
display: 'flex',
33+
flexDirection: 'column',
34+
gap: tokens.gap,
35+
},
36+
}),
37+
['gap'],
2838
),
2939
},
3040
};

packages/components/Menu/src/MenuList/MenuList.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import React from 'react';
44
import { Platform, ScrollView, View } from 'react-native';
55

6-
import type { IViewProps } from '@fluentui-react-native/adapters';
76
import { FocusZone } from '@fluentui-react-native/focus-zone';
87
import type { UseSlots } from '@fluentui-react-native/framework';
9-
import { compose, mergeProps, stagedComponent, withSlots } from '@fluentui-react-native/framework';
8+
import { compose, withSlots } from '@fluentui-react-native/framework';
109

1110
import { stylingSettings } from './MenuList.styling';
1211
import type { MenuListProps, MenuListState, MenuListType } from './MenuList.types';
@@ -15,25 +14,6 @@ import { useMenuList } from './useMenuList';
1514
import { useMenuListContextValue } from './useMenuListContextValue';
1615
import { MenuListProvider } from '../context/menuListContext';
1716

18-
const MenuStack = stagedComponent((props: React.PropsWithRef<IViewProps> & { gap?: number }) => {
19-
const { gap, ...rest } = props;
20-
return (final: React.PropsWithRef<IViewProps> & { gap?: number }, children: React.ReactNode) => {
21-
if (gap && gap > 0 && children) {
22-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
23-
// @ts-ignore - GH:1684, fix typing error
24-
children = React.Children.map(children, (child: React.ReactChild, index: number) => {
25-
if (React.isValidElement(child) && index > 0) {
26-
return React.cloneElement(child, mergeProps(child.props, { style: { marginTop: gap } }));
27-
}
28-
return child;
29-
});
30-
}
31-
32-
return <View {...mergeProps(rest, final)}>{children}</View>;
33-
};
34-
});
35-
MenuStack.displayName = 'MenuStack';
36-
3717
const shouldHaveFocusZone = ['macos', 'win32'].includes(Platform.OS as string);
3818
const focusLandsOnContainer = Platform.OS === 'macos';
3919
const hasCircularNavigation = Platform.OS === ('win32' as any);
@@ -46,9 +26,9 @@ export const MenuList = compose<MenuListType>({
4626
displayName: menuListName,
4727
...stylingSettings,
4828
slots: {
49-
root: MenuStack,
29+
root: View,
5030
scrollView: ScrollView,
51-
focusZone: shouldHaveFocusZone ? FocusZone : React.Fragment,
31+
focusZone: shouldHaveFocusZone ? FocusZone : View,
5232
},
5333
useRender: (userProps: MenuListProps, useSlots: UseSlots<MenuListType>) => {
5434
const menuList = useMenuList(userProps);

0 commit comments

Comments
 (0)