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

Datagrid: Do not prevent page scroll if we are not actually scrolling the grid #446

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
19 changes: 17 additions & 2 deletions packages/datagrid/src/basicmousehandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,23 @@ export class BasicMouseHandler implements DataGrid.IMouseHandler {
throw 'unreachable';
}

// Scroll by the desired amount.
grid.scrollBy(dx, dy);
// Only scroll and stop the event propagation if needed.
if (
// Scrolling left and not reached min already
(dx < 0 && grid.scrollX !== 0) ||
// Scrolling right and not reached max already
(dx > 0 && grid.scrollX !== grid.maxScrollX) ||
// Scrolling top and not reached min already
(dy < 0 && grid.scrollY !== 0) ||
// Scrolling down and not reached max already
(dy > 0 && grid.scrollY !== grid.maxScrollY)
) {
event.preventDefault();
event.stopPropagation();

// Scroll by the desired amount.
grid.scrollBy(dx, dy);
}
}

/**
Expand Down
4 changes: 0 additions & 4 deletions packages/datagrid/src/datagrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3088,10 +3088,6 @@ export class DataGrid extends Widget {
return;
}

// Stop the event propagation.
event.preventDefault();
event.stopPropagation();

// Dispatch to the mouse handler.
this._mouseHandler.onWheel(this, event);
}
Expand Down