Skip to content
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
2 changes: 1 addition & 1 deletion src/hooks/useScrollDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function useScrollDrag(

const onMouseDown = (e: MouseEvent) => {
// Skip if element set draggable
if ((e.target as HTMLElement).draggable) {
if ((e.target as HTMLElement).draggable || e.button !== 0) {
return;
}
// Skip if nest List has handled this event
Expand Down
26 changes: 24 additions & 2 deletions tests/scroll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,10 @@ describe('List.Scroll', () => {
});

describe('mouse down drag', () => {
function dragDown(container, mouseY) {
fireEvent.mouseDown(container.querySelector('li'));
function dragDown(container, mouseY, button = 0) {
fireEvent.mouseDown(container.querySelector('li'), {
button,
});

let moveEvent = createEvent.mouseMove(container.querySelector('li'));
moveEvent.pageY = mouseY;
Expand Down Expand Up @@ -621,6 +623,26 @@ describe('List.Scroll', () => {
expect(getScrollTop(container)).toBe(0);
});

it('right click should not move', () => {
const onScroll = jest.fn();
const { container } = render(
<List
component="ul"
itemKey="id"
itemHeight={20}
height={100}
data={genData(100)}
onScroll={onScroll}
>
{({ id }) => <li>{id}</li>}
</List>,
);

// Drag down
dragDown(container, 100, 2);
expect(getScrollTop(container)).toBe(0);
});

it('can not move when item add draggable', () => {
const onScroll = jest.fn();
const { container } = render(
Expand Down
Loading