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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix autoscroll bugs that cause wonkly behaviors #835
Conversation
@@ -515,7 +515,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p, | |||
const isTouch = (ev !== undefined && !(ev instanceof MouseEvent)) || (ev as any)?.pointerType === "touch"; | |||
|
|||
const scrollEdge: GridMouseEventArgs["scrollEdge"] = [ | |||
x < stickyX ? -1 : rect.width < x ? 1 : 0, | |||
x < 0 ? -1 : rect.width < x ? 1 : 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would know if the current selection is inside the freeze region or not, but since this is not currently known in this region of the code I didn't want to plumb it through. We could then conditionally scroll. For now however this will have to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the benefit if we would know the freeze region here? Are there any problematic scenarios with just doing x < 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I initially used stickyX
since I wanted autoscroll to occur when the cursor is over the rowMarkers, similar to how it vertically scrolls if you're in the column headers.
But yeah, stickyX
isn't the right prop for it since it's dependent on fixedShadowX = true
.
const stickyX = fixedShadowX ? getStickyWidth(mappedColumns, dragAndDropState) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problematic scenario here is that with x < 0
you don't get autoscroll until you rmouse leaves the grid entirely. Ideally auto-scroll would start if you go over a sticky column and the current selected cell is not in the sticky region.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me :) but I don't have a very good understanding of the surrounding code yet.
@@ -515,7 +515,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p, | |||
const isTouch = (ev !== undefined && !(ev instanceof MouseEvent)) || (ev as any)?.pointerType === "touch"; | |||
|
|||
const scrollEdge: GridMouseEventArgs["scrollEdge"] = [ | |||
x < stickyX ? -1 : rect.width < x ? 1 : 0, | |||
x < 0 ? -1 : rect.width < x ? 1 : 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the benefit if we would know the freeze region here? Are there any problematic scenarios with just doing x < 0
?
@@ -515,7 +515,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p, | |||
const isTouch = (ev !== undefined && !(ev instanceof MouseEvent)) || (ev as any)?.pointerType === "touch"; | |||
|
|||
const scrollEdge: GridMouseEventArgs["scrollEdge"] = [ | |||
x < stickyX ? -1 : rect.width < x ? 1 : 0, | |||
x < 0 ? -1 : rect.width < x ? 1 : 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I initially used stickyX
since I wanted autoscroll to occur when the cursor is over the rowMarkers, similar to how it vertically scrolls if you're in the column headers.
But yeah, stickyX
isn't the right prop for it since it's dependent on fixedShadowX = true
.
const stickyX = fixedShadowX ? getStickyWidth(mappedColumns, dragAndDropState) : 0; |
No description provided.