Skip to content

Commit

Permalink
fix(react-menu): remove unwanted aria attributes on context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bsunderhus committed Nov 10, 2022
1 parent d1228a1 commit 98ec8dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: remove unwanted aria attributes on context menu",
"packageName": "@fluentui/react-menu",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type MenuTriggerProps = TriggerProps<MenuTriggerChildProps> & {
export type MenuTriggerChildProps<Type extends ARIAButtonType = ARIAButtonType, Props = {}> = ARIAButtonResultProps<
Type,
Props & {
'aria-haspopup': 'menu';
'aria-haspopup'?: 'menu';
'aria-expanded'?: boolean;
id: string;
ref: React.Ref<never>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,22 @@ export const useMenuTrigger_unstable = (props: MenuTriggerProps): MenuTriggerSta
};

const contextMenuProps = {
'aria-haspopup': 'menu',
'aria-expanded': !open && !isSubmenu ? undefined : open,
id: triggerId,
...child?.props,
ref: useMergedRefs(triggerRef, child?.ref),
onMouseEnter: useEventCallback(mergeCallbacks(child?.props.onMouseEnter, onMouseEnter)),
onMouseLeave: useEventCallback(mergeCallbacks(child?.props.onMouseLeave, onMouseLeave)),
onContextMenu: useEventCallback(mergeCallbacks(child?.props.onContextMenu, onContextMenu)),
onMouseMove: useEventCallback(mergeCallbacks(child?.props.onMouseMove, onMouseMove)),
} as const;
};

const triggerChildProps = {
'aria-haspopup': 'menu',
'aria-expanded': !open && !isSubmenu ? undefined : open,
...contextMenuProps,
onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),
onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),
};
} as const;

const ariaButtonTriggerChildProps = useARIAButtonProps(
child?.type === 'button' || child?.type === 'a' ? child.type : 'div',
Expand Down

0 comments on commit 98ec8dd

Please sign in to comment.