Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/E2E/src/Menu/specs/Menu.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ describe('Menu Functional Testing', () => {
.toBeFalsy();
});

it('Press "Tab" to navigate between MenuItems. Validate that focus switches correctly between MenuItems.', async () => {
it('Press "Tab" to navigate between MenuGroups. Validate that focus switches correctly between MenuGroups.', async () => {
await MenuPageObject.openMenu();

await MenuPageObject.sendKeys(MenuPageObject.getMenuItem('Third'), [Keys.TAB]);
await MenuPageObject.sendKeys(MenuPageObject.getMenuItem('First'), [Keys.TAB]);
expect(
await MenuPageObject.compareAttribute(MenuPageObject.getMenuItem('Fourth'), Attribute.IsFocused, AttributeValue.true),
await MenuPageObject.compareAttribute(MenuPageObject.getMenuItem('Third'), Attribute.IsFocused, AttributeValue.true),
).toBeTruthy();

await MenuPageObject.sendKeys(MenuPageObject.getMenuItem('Fourth'), [Keys.TAB]);
await MenuPageObject.sendKeys(MenuPageObject.getMenuItem('Third'), [Keys.TAB]);
expect(
await MenuPageObject.compareAttribute(MenuPageObject.getMenuItem('First'), Attribute.IsFocused, AttributeValue.true),
).toBeTruthy();
Expand Down
67 changes: 36 additions & 31 deletions apps/fluent-tester/src/TestComponents/Menu/E2EMenuTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { View } from 'react-native';

import { ButtonV1 as Button } from '@fluentui-react-native/button';
import { Menu, MenuItem, MenuList, MenuPopover, MenuTrigger } from '@fluentui-react-native/menu';
import { Menu, MenuDivider, MenuGroup, MenuItem, MenuList, MenuPopover, MenuTrigger } from '@fluentui-react-native/menu';
import { Stack } from '@fluentui-react-native/stack';
import { TextV1 as Text } from '@fluentui-react-native/text';

Expand Down Expand Up @@ -76,36 +76,41 @@ export const E2EMenuTest: React.FunctionComponent = () => {
{...testProps(MENUPOPOVER_TEST_COMPONENT)}
>
<MenuList>
<MenuItem
onClick={onItemClick}
accessibilityLabel={MENUITEM_ACCESSIBILITY_LABEL}
persistOnClick
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_TEST_COMPONENT)}
>
A plain MenuItem
</MenuItem>
<MenuItem
onClick={onItemClick}
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_DISABLED_COMPONENT)}
disabled
persistOnClick
>
A second disabled plain MenuItem
</MenuItem>
<MenuItem
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_NO_A11Y_LABEL_COMPONENT)}
>
{MENUITEM_TEST_LABEL}
</MenuItem>
<MenuItem
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_FOURTH_COMPONENT)}
>
A fourth plain MenuItem
</MenuItem>
<MenuGroup>
<MenuItem
onClick={onItemClick}
accessibilityLabel={MENUITEM_ACCESSIBILITY_LABEL}
persistOnClick
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_TEST_COMPONENT)}
>
A plain MenuItem
</MenuItem>
<MenuItem
onClick={onItemClick}
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_DISABLED_COMPONENT)}
disabled
persistOnClick
>
A second disabled plain MenuItem
</MenuItem>
</MenuGroup>
<MenuDivider />
<MenuGroup>
<MenuItem
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_NO_A11Y_LABEL_COMPONENT)}
>
{MENUITEM_TEST_LABEL}
</MenuItem>
<MenuItem
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(MENUITEM_FOURTH_COMPONENT)}
>
A fourth plain MenuItem
</MenuItem>
</MenuGroup>
</MenuList>
</MenuPopover>
</Menu>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "update E2E test for win32",
"packageName": "@fluentui-react-native/e2e-testing",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix Menu tab navigation on win32",
"packageName": "@fluentui-react-native/menu",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "update E2E test for win32",
"packageName": "@fluentui-react-native/tester",
"email": "[email protected]",
"dependentChangeType": "patch"
}
8 changes: 7 additions & 1 deletion packages/components/Menu/src/MenuList/MenuList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ MenuStack.displayName = 'MenuStack';
const shouldHaveFocusZone = ['macos', 'win32'].includes(Platform.OS as string);
const focusLandsOnContainer = Platform.OS === 'macos';
const hasCircularNavigation = Platform.OS === ('win32' as any);
const hasTabNavigation = Platform.OS === ('win32' as any);

export const menuListLookup = (layer: string, state: MenuListState, userProps: MenuListProps): boolean => {
return state[layer] || userProps[layer] || layer === 'hasMaxHeight';
Expand Down Expand Up @@ -84,6 +83,13 @@ export const MenuList = compose<MenuListType>({
const shouldHaveScrollView = Platform.OS === 'macos' || menuList.hasMaxHeight || menuList.hasMaxWidth;
const ScrollViewWrapper = shouldHaveScrollView ? Slots.scrollView : React.Fragment;

const hasMenuGroupChild = React.Children.toArray(children).some(
(child) => child && (child as any).type && (child as any).type.displayName === 'MenuGroup',
);

// On win32, tab navigation should only be enabled when we have menu groups.
const hasTabNavigation = Platform.OS === ('win32' as any) && hasMenuGroupChild;

const content = (
<Slots.root>
<ScrollViewWrapper
Expand Down