Don't render context menu when scrolling (#30613)
* Don't render context menu when scrolling * Add test to check context menu is not rendered when scrolling * Add comment.
This commit is contained in:
@@ -37,6 +37,7 @@ describe("<RoomListItemView />", () => {
|
||||
onFocus: jest.fn(),
|
||||
roomIndex: 0,
|
||||
roomCount: 1,
|
||||
listIsScrolling: false,
|
||||
};
|
||||
|
||||
return render(<RoomListItemView {...defaultProps} {...props} />, withClientContextRenderOptions(matrixClient));
|
||||
@@ -128,6 +129,7 @@ describe("<RoomListItemView />", () => {
|
||||
onFocus={jest.fn()}
|
||||
roomIndex={0}
|
||||
roomCount={1}
|
||||
listIsScrolling={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -191,4 +193,26 @@ describe("<RoomListItemView />", () => {
|
||||
await user.keyboard("{Escape}");
|
||||
expect(screen.queryByRole("menu")).toBeNull();
|
||||
});
|
||||
|
||||
test("should not render context menu when list is scrolling", async () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
mocked(useRoomListItemViewModel).mockReturnValue({
|
||||
...defaultValue,
|
||||
showContextMenu: true,
|
||||
});
|
||||
|
||||
renderRoomListItem({
|
||||
listIsScrolling: true,
|
||||
});
|
||||
|
||||
const button = screen.getByRole("option", { name: `Open room ${room.name}` });
|
||||
await user.pointer([{ target: button }, { keys: "[MouseRight]", target: button }]);
|
||||
|
||||
// Context menu should not appear when scrolling
|
||||
expect(screen.queryByRole("menu")).toBeNull();
|
||||
|
||||
// But the room item itself should still be rendered
|
||||
expect(button).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user