Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const NestedContextualMenu: React.FunctionComponent = () => {
itemKey="4"
onHoverIn={toggleShowSubmenu}
componentRef={stdMenuItemRef}
expanded={showSubmenu}
/>
{showSubmenu && (
<Submenu target={stdMenuItemRef} onDismiss={onDismissSubmenu} onShow={onShowSubmenu} setShowMenu={toggleShowSubmenu}>
Expand Down Expand Up @@ -446,6 +447,7 @@ const ScrollViewContextualMenu: React.FunctionComponent = () => {
itemKey="3"
onHoverIn={toggleShowSubmenu}
componentRef={stdMenuItemRef}
expanded={showSubmenu}
/>
{showSubmenu && (
<Submenu
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix narrator bug",
"packageName": "@fluentui-react-native/contextual-menu",
"email": "gulnazsayed@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix narrator bug",
"packageName": "@fluentui-react-native/tester",
"email": "gulnazsayed@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import type * as React from 'react';

import type { IViewProps } from '@fluentui-react-native/adapters';
import type { IconProps } from '@fluentui-react-native/icon';
import type { IFocusable, IPressableState } from '@fluentui-react-native/interactive-hooks';
import type { IPressableProps } from '@fluentui-react-native/pressable';
import type { IFocusable, IPressableState, PressablePropsExtended } from '@fluentui-react-native/interactive-hooks';
import type { ITextProps } from '@fluentui-react-native/text';
import type { FontTokens, IForegroundColorTokens, IBackgroundColorTokens, IBorderTokens } from '@fluentui-react-native/tokens';
import type { IRenderData } from '@uifabricshared/foundation-composable';
Expand Down Expand Up @@ -48,7 +47,7 @@ export interface ContextualMenuItemTokens extends FontTokens, IForegroundColorTo
iconWeight?: number;
}

export interface ContextualMenuItemProps extends Omit<IPressableProps, 'onPress'> {
export interface ContextualMenuItemProps extends Omit<PressablePropsExtended, 'onPress'> {
/*
** A unique key-identifier for each menu item
*/
Expand Down
25 changes: 22 additions & 3 deletions packages/components/ContextualMenu/src/SubmenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const SubmenuItem = compose<SubmenuItemType>({
const defaultComponentRef = React.useRef(null);
const {
disabled,
expanded,
itemKey,
icon,
text,
Expand Down Expand Up @@ -147,23 +148,41 @@ export const SubmenuItem = compose<SubmenuItemType>({
const onKeyDownProps = useKeyDownProps(showSubmenuOnKeyDown, ' ', 'Enter', 'ArrowLeft', 'ArrowRight');
const onAccTap = onAccessibilityTap ?? onItemPress;

// grab the styling information, referencing the state as well as the props
// Default accessibility actions to help screen readers announce expanded/collapsed state
const defaultAccessibilityActions = React.useMemo(
() => [
Comment thread
Saadnajmi marked this conversation as resolved.
Outdated
{ name: 'Expand', label: 'Expand submenu' },
{ name: 'Collapse', label: 'Collapse submenu' },
],
[],
);

// Merge user accessibility actions with defaults
const finalAccessibilityActions = React.useMemo(() => {
const userActions = userProps.accessibilityActions;
if (userActions && userActions.length > 0) {
return [...defaultAccessibilityActions, ...userActions];
}
return defaultAccessibilityActions;
}, [userProps.accessibilityActions, defaultAccessibilityActions]);

const styleProps = useStyling(userProps, (override: string) => state[override] || userProps[override]);
// create the merged slot props
const slotProps = mergeSettings<SubmenuItemSlotProps>(styleProps, {
root: {
ref: cmRef,
...pressablePropsModified,
...onKeyDownProps,
...rest,
accessible: true,
accessibilityLabel: accessibilityLabel,
accessibilityRole: 'menuitem',
accessibilityState: { disabled: state.disabled ?? false, selected: state.selected },
accessibilityState: { disabled: state.disabled ?? false, expanded: expanded ?? false, selected: state.selected },
accessibilityValue: { text: itemKey },
accessibilityActions: finalAccessibilityActions,
disabled,
focusable: !disabled,
onAccessibilityTap: onAccTap,
...rest,
},
content: {
accessible: false,
Expand Down
7 changes: 6 additions & 1 deletion packages/components/ContextualMenu/src/SubmenuItem.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export const submenuItemName = 'SubmenuItem';
export interface SubmenuItemTokens extends ContextualMenuItemTokens {
chevronColor?: string;
}
export type SubmenuItemProps = ContextualMenuItemProps;
export interface SubmenuItemProps extends ContextualMenuItemProps {
/**
* Whether the submenu is currently expanded/visible
*/
expanded?: boolean;
}

export type SubmenuItemState = ContextualMenuItemState;

Expand Down