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 scrollDirection when direction is RTL #690

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

DevinFrenze
Copy link
Contributor

@DevinFrenze DevinFrenze commented Nov 30, 2022

To determine the scrollDirection in the _onScrollHorizontal method it compares the previous state's scrollOffset with the current scrollLeft value of the target. For browsers whose "RTLOffsetType" is "negative", this results in the scrollDirection being set to "backward".

The scrollOffset state value has been converted to a positive number or zero, and the scrollLeft value of the target (when "RTLOffsetType" is "negative") is a negative number. When comparing prevState.scrollOffset < scrollLeft it is always false because a positive value or zero is never greater than a negative value.

Proposed fix: compare prevState.scrollOffset < scrollOffset because scrollOffset has already been transformed in the same way that prevState.scrollOffset was transformed.

This pull request is intended to address this bug #689.

@DevinFrenze
Copy link
Contributor Author

DevinFrenze commented Jan 3, 2023

@bvaughn sorry to ping you, but if you have a moment to glance at this and let me know if you think it's a reasonable change i would appreciate it. i'm using react-window in a project and would much rather get this change in and use the main repo than be using a fork indefinitely.

and for what it's worth i have tested this some amount and believe that it works as expected.

@DevinFrenze
Copy link
Contributor Author

@bvaughn i'm requesting your review here. let me know if there's someone else i should reach out to for review.

Copy link
Owner

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

I think this change looks reasonable. I haven't worked in this code in many months though so I'm not totally confident in my own assessment. Have you tested it?

@DevinFrenze
Copy link
Contributor Author

I tested it in a project that I'm developing and it works well there, and it doesn't change behavior when using react-window left-to-right. Of course, there may be edge cases I don't know about.

@bvaughn
Copy link
Owner

bvaughn commented Nov 22, 2023

That's fair. Okay!

@bvaughn bvaughn merged commit 7853dd3 into bvaughn:master Nov 22, 2023
@bvaughn
Copy link
Owner

bvaughn commented Nov 22, 2023

@DevinFrenze Please check 1.8.10 (just published) and confirm the fix?

@DevinFrenze
Copy link
Contributor Author

@bvaughn it appears to be working well ! thanks for merging

@bvaughn
Copy link
Owner

bvaughn commented Nov 28, 2023

No problem. Thanks for verifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants