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 subscript avatar color doesn't reset when unhovered #56234

Merged
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
1 change: 1 addition & 0 deletions src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function BaseListItem<TItem extends ListItem>({
// Sync focus on an item
useSyncFocus(pressableRef, !!isFocused, shouldSyncFocus);
const handleMouseLeave = (e: React.MouseEvent<Element, MouseEvent>) => {
bind.onMouseLeave();
e.stopPropagation();
setMouseUp();
};
Expand Down
35 changes: 35 additions & 0 deletions tests/ui/BaseListItemTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {fireEvent, render, screen} from '@testing-library/react-native';
import BaseListItem from '@components/SelectionList/BaseListItem';
import useHover from '@hooks/useHover';
import CONST from '@src/CONST';

jest.mock('@hooks/useHover', () => jest.fn());

const mockedUseHover = useHover as jest.MockedFunction<typeof useHover>;

describe('BaseListItem', () => {
it('hover should work correctly', () => {
const mouseEnterMock = jest.fn();
const mouseLeaveMock = jest.fn();
mockedUseHover.mockReturnValue({
hovered: false,
bind: {
onMouseEnter: mouseEnterMock,
onMouseLeave: mouseLeaveMock,
},
});
render(
<BaseListItem
item={{keyForList: '1'}}
onSelectRow={() => {}}
showTooltip={false}
isFocused={false}
/>,
);
const testID = `${CONST.BASE_LIST_ITEM_TEST_ID}1`;
fireEvent(screen.getByTestId(testID), 'mouseEnter');
expect(mouseEnterMock).toBeCalled();
fireEvent(screen.getByTestId(testID), 'mouseLeave', {stopPropagation: jest.fn()});
expect(mouseLeaveMock).toBeCalled();
});
});