Skip to content

Commit

Permalink
Merge pull request #56234 from bernhardoj/fix/56015-unhover-doesnt-work
Browse files Browse the repository at this point in the history
Fix subscript avatar color doesn't reset when unhovered
  • Loading branch information
luacmartins authored Feb 4, 2025
2 parents bfb97c5 + d1f8c96 commit e36d812
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
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();
});
});

0 comments on commit e36d812

Please sign in to comment.