Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove MenuItem focus on hover #33577

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual regressions to review in the fluentuiv9 Visual Regression Report

Avatar Converged 2 screenshots
Image Name Diff(in Pixels) Image Type
Avatar Converged.Badge Mask RTL.chromium.png 4 Changed
Avatar Converged.badgeMask.chromium.png 16 Changed

"type": "patch",
"comment": "fix: Remove MenuItem focus on hover",
"packageName": "@fluentui/react-menu",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,27 +255,6 @@ describe('MenuItem', () => {
.get(menuSelector)
.should('be.visible');
});

it('should focus on hover', () => {
mount(
<Menu>
<MenuTrigger disableButtonEnhancement>
<button id={menuTriggerId}>Menu</button>
</MenuTrigger>
<MenuPopover>
<MenuList>
<MenuItem>Item</MenuItem>
</MenuList>
</MenuPopover>
</Menu>,
);
cy.get(menuTriggerSelector)
.trigger('click')
.get(menuItemSelector)
.each(el => {
cy.wrap(el).trigger('mouseover').should('be.focused');
});
});
});

describe('MenuItemCheckbox', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ describe('MenuItem', () => {
expect(tree).toMatchSnapshot();
});

it('should focus the item on mouseenter', () => {
// Arrange
const { getByRole } = render(<MenuItem>Item</MenuItem>);

// Act
const menuitem = getByRole('menuitem');
fireEvent.mouseEnter(menuitem);

// Assert
expect(document.activeElement).toBe(menuitem);
});

it('should render submenu indicator icon if wrapped by menu trigger context', () => {
// Arrange
const slot = 'submenu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ exports[`MenuItem renders a default state 1`] = `
onClick={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseEnter={[Function]}
role="menuitem"
tabIndex={0}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ export const useMenuItem_unstable = (props: MenuItemProps, ref: React.Ref<ARIABu
dismissedWithKeyboardRef.current = true;
}
}),
onMouseEnter: useEventCallback(event => {
innerRef.current?.focus();

props.onMouseEnter?.(event);
}),
onClick: useEventCallback(event => {
if (!hasSubmenu && !persistOnClick) {
setOpen(event, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`MenuItemCheckbox conformance renders a default state 1`] = `
onClick={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseEnter={[Function]}
role="menuitemcheckbox"
tabIndex={0}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`MenuItemRadio renders a default state 1`] = `
onClick={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseEnter={[Function]}
role="menuitemradio"
tabIndex={0}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ const mount = (element: JSX.Element) => {
mountBase(<FluentProvider theme={teamsLightTheme}>{element}</FluentProvider>);
};
describe('MenuList', () => {
it('should focus each menu item on hover', () => {
mount(
<div style={{ width: 'max-content', border: '1px solid black', paddingTop: 4, paddingBottom: 4 }}>
<MenuList>
<MenuItem>Cut</MenuItem>
<MenuItem>Paste</MenuItem>
<MenuItem>Edit</MenuItem>
</MenuList>
</div>,
);
cy.get(menuItemSelector).each(el => {
cy.wrap(el).trigger('mouseover').should('be.focused');
});
});

describe('With nested submenus', () => {
const Example = () => {
return (
Expand Down
Loading