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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autoscroll bugs that cause wonkly behaviors #835

Merged
merged 2 commits into from Dec 28, 2023

Conversation

jassmith
Copy link
Contributor

No description provided.

@jassmith jassmith requested review from BrianHung and LukasMasuch and removed request for BrianHung December 28, 2023 18:27
@@ -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,
Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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;

Copy link
Contributor Author

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.

Copy link
Collaborator

@LukasMasuch LukasMasuch left a 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,
Copy link
Collaborator

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,
Copy link
Collaborator

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;

packages/core/src/data-editor/data-editor.tsx Show resolved Hide resolved
@jassmith jassmith merged commit fc0d331 into 6.0.0 Dec 28, 2023
6 checks passed
@jassmith jassmith deleted the jason/fix-auto-scroll-bugs branch December 28, 2023 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants