-
Notifications
You must be signed in to change notification settings - Fork 290
Fix scrollbar thumb crashing in React@next (v19) #718
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
Conversation
@@ -27,23 +27,18 @@ | |||
.ScrollbarLayout/mainHorizontal { | |||
height: var(--scrollbar-size); | |||
left: 0; | |||
transition-property: background-color height; |
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.
Moved to the thumb element (see :after
) which is the actual element that needs the animation
/* Touching the scroll-track directly makes the scroll-track bolder */ | ||
.ScrollbarLayout/mainHorizontal.public/Scrollbar/mainActive, | ||
.ScrollbarLayout/mainHorizontal:hover { | ||
height: var(--scrollbar-size-large); |
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.
Removed scrollbar-size-large
since it was changing the height of the scrollbar wrapper element thus in turn very slightly modifying the layout of the table.
transition-duration: 250ms; | ||
transition-timing-function: ease; | ||
transition-property: background-color, height, width; |
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.
nit: should this be turned into a single line?
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.
do we have any advantage of that?
code wise i think its fine
@@ -67,10 +64,8 @@ | |||
} | |||
|
|||
.ScrollbarLayout/faceHorizontal:after { | |||
bottom: var(--scrollbar-face-margin); |
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.
Previously, top, bottom, left, right were set to align the thumb in the center of the scrollbar face element.
This is a bit hard to read and manage, and we can instead simplify this with flex layout.
onFocus={this._onFocus} | ||
onBlur={this._onBlur} |
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.
We no longer need to manage blurring or focusing the scrollbar.
@@ -244,9 +240,6 @@ class Scrollbar extends React.PureComponent { | |||
this._mouseMoveTracker.releaseMouseMoves(); | |||
this._mouseMoveTracker = null; | |||
} | |||
if (_lastScrolledScrollbar === this) { |
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.
We no longer need to track the last scrolled scrollbar.
LGTM |
Released with v2.0.9. |
Description
Trying to interact with FDT's scrollbar on latest React (react@next or react@19 at the time of writing) crashes the whole app with the following error:
This confirms that
ReactDOM.findDOMNode
which was already marked as deprecated is now removed in a future version of React.Furthermore, once a scrollbar is active, it never goes into an inactive state even after stopping scroll or moving the cursor away from the scrollbar. Animations are also semi-broken...
Context
We've been using
ReactDOM.findDOMNode
in our scrollbar component to get a reference to the scrollbar DOM so as to blur it out.Digging through the code, this looks like it was simply done to figure out if the scrollbar is in an active state of use.
Technically we don't need to any of this, and we can instead rely on
DOMMouseMoveTracker
to figure out if the user is dragging and using the scrollbar.Fixes
I'm fixing all of this by cleaning up a bit of the Scrollbar component such that:
scrollbar-size-large
Screenshot
Inactive scrollbars

Active horizontal scrollbar

Active vertical scrollbar

How Has This Been Tested?
Tested on local examples having multiple scrollbars.
Types of changes
Checklist: