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

Fix scrolling in variables view for web #5513

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Conversation

timtmok
Copy link
Contributor

@timtmok timtmok commented Nov 26, 2024

Address #5473

Adds a mouse wheel listener to the div containing list and forward it to the List component. I tried to wrap everything in a Scrollable but it would take more time to get everything working the same way. The List component does some extra list virtualization for performance that I didn't want to risk touching that the Scrollable would have to replace.

QA Notes

Creating enough variables to fill more than the Variables view is one way to test. Another is creating a dataframe and expanding some of the data in it.

#Python
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
#R
df <- iris

@timtmok timtmok requested a review from sharon-wang November 26, 2024 14:56
Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vertical scroll is working for me on Mac in a Server Web dev build 👍

In Web and Desktop, I noticed there's some left/right scrolling as well when I scroll vertically, likely because I'm using a touchpad instead of a mouse wheel. It doesn't seem to be because of limited horizontal space -- perhaps a separate issue if it's not a quick fix, as this is an existing problem!

Also separate, a UX improvement thought: maybe we could "freeze" the expanded object/dataframe/etc title row until the user scrolls through all the nested contents. For example, in the video, we could freeze the df row, and then also the Petal.Length rows until we scroll through the nested elements.

variables_vertical_scroll_left_right.mp4

@@ -513,6 +513,17 @@ export const VariablesInstance = (props: VariablesInstanceProps) => {
}
};

// workaround for web disabling scrolling on the window to prevent URL navigation
useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we're using useEffect here instead of adding an onWheel to the div? I think the other places we've added this fix used onWheel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's better this way but it makes sense to be consistent everywhere. I just happened to be trying out different ways to figure out the correct elements to add the wheel listener since the List component doesn't expose its div container.

Comment on lines 518 to 524
if (!isWeb) {
return;
}

outerRef.current?.addEventListener('wheel', (e: WheelEvent) => {
innerRef.current.parentElement?.scrollBy(e.deltaX, e.deltaY);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reasonable way to pull this onWheel logic into a util function that can be reused across all the places we are adding this handling? It could make it easier to keep track of the places we have this handling, as well as have a single place to update the implementation if needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the easiest way to search for all instances currently is using the search term scrollBy(e.deltaX, e.deltaY)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think creating a custom React hook might be able to fulfill this. As long as it has access to the element that receives the scroll event and the element that needs to receive the scroll data (they can be different). This might be an easier way to deal with this bug over using the Scrollable so that it's more React compatible.

@timtmok
Copy link
Contributor Author

timtmok commented Nov 26, 2024

Also separate, a UX improvement thought: maybe we could "freeze" the expanded object/dataframe/etc title row until the user scrolls through all the nested contents. For example, in the video, we could freeze the df row, and then also the Petal.Length rows until we scroll through the nested elements.

variables_vertical_scroll_left_right.mp4

I noticed this too and it also exists on desktop. I think the styling or sizing on the content is 1px off.

@timtmok timtmok requested a review from sharon-wang November 26, 2024 18:46
Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@timtmok timtmok merged commit 54cbc06 into main Nov 26, 2024
4 checks passed
@timtmok timtmok deleted the bugfix/5473-variable-scroll-web branch November 26, 2024 19:06
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants