-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,23 +27,18 @@ | |
.ScrollbarLayout/mainHorizontal { | ||
height: var(--scrollbar-size); | ||
left: 0; | ||
transition-property: background-color height; | ||
} | ||
|
||
/* 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 commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
} | ||
|
||
.ScrollbarLayout/face { | ||
left: 0; | ||
overflow: hidden; | ||
position: absolute; | ||
z-index: 1; | ||
transition-duration: 250ms; | ||
transition-timing-function: ease; | ||
transition-property: width; | ||
|
||
/* keep the thumb aligned to the center */ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
/** | ||
|
@@ -57,7 +52,9 @@ | |
content: ''; | ||
display: block; | ||
position: absolute; | ||
transition: background-color 250ms ease; | ||
transition-duration: 250ms; | ||
transition-timing-function: ease; | ||
transition-property: background-color, height, width; | ||
Comment on lines
+55
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. do we have any advantage of that? |
||
} | ||
|
||
.ScrollbarLayout/faceHorizontal { | ||
|
@@ -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 commentThe 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. |
||
left: 0; | ||
top: var(--scrollbar-face-margin); | ||
width: 100%; | ||
height: calc(100% - var(--scrollbar-face-margin) * 2); | ||
} | ||
|
||
.fixedDataTable_isRTL .ScrollbarLayout/faceHorizontal, | ||
|
@@ -79,9 +74,10 @@ | |
left: auto; | ||
} | ||
|
||
/* expand horizontal scrollbar face when active */ | ||
.ScrollbarLayout/faceHorizontal.public/Scrollbar/faceActive:after, | ||
.ScrollbarLayout/main:hover .ScrollbarLayout/faceHorizontal:after { | ||
bottom: calc(var(--scrollbar-face-margin)/2); | ||
height: calc(100% - var(--scrollbar-face-margin)); | ||
} | ||
|
||
.ScrollbarLayout/faceVertical { | ||
|
@@ -92,13 +88,11 @@ | |
|
||
.ScrollbarLayout/faceVertical:after { | ||
height: 100%; | ||
left: var(--scrollbar-face-margin); | ||
right: var(--scrollbar-face-margin); | ||
top: 0; | ||
width: calc(100% - var(--scrollbar-face-margin) * 2); | ||
} | ||
|
||
/* expand veritcal scrollbar face when active */ | ||
.ScrollbarLayout/main:hover .ScrollbarLayout/faceVertical:after, | ||
.ScrollbarLayout/faceVertical.public/Scrollbar/faceActive:after { | ||
left: calc(var(--scrollbar-face-margin)/2); | ||
right: calc(var(--scrollbar-face-margin)/2); | ||
width: calc(100% - var(--scrollbar-face-margin)); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,6 @@ const FACE_MARGIN_2 = FACE_MARGIN * 2; | |
const FACE_SIZE_MIN = 30; | ||
const KEYBOARD_SCROLL_AMOUNT = 40; | ||
|
||
let _lastScrolledScrollbar = null; | ||
|
||
class Scrollbar extends React.PureComponent { | ||
static propTypes = { | ||
contentSize: PropTypes.number.isRequired, | ||
|
@@ -110,7 +108,7 @@ class Scrollbar extends React.PureComponent { | |
let faceStyle; | ||
const isHorizontal = this.state.isHorizontal; | ||
const isVertical = !isHorizontal; | ||
const isActive = this.state.focused || this.state.isDragging; | ||
const isActive = this.state.isDragging; | ||
const faceSize = this.state.faceSize; | ||
const isOpaque = this.props.isOpaque; | ||
const verticalTop = this.props.verticalTop || 0; | ||
|
@@ -182,8 +180,6 @@ class Scrollbar extends React.PureComponent { | |
|
||
return ( | ||
<div | ||
onFocus={this._onFocus} | ||
onBlur={this._onBlur} | ||
Comment on lines
-185
to
-186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer need to manage blurring or focusing the scrollbar. |
||
onKeyDown={this._onKeyDown} | ||
onMouseDown={this._onMouseDown} | ||
onTouchCancel={this._onTouchCancel} | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. We no longer need to track the last scrolled scrollbar. |
||
_lastScrolledScrollbar = null; | ||
} | ||
} | ||
|
||
scrollBy = (/*number*/ delta) => { | ||
|
@@ -313,15 +306,10 @@ class Scrollbar extends React.PureComponent { | |
position = maxPosition; | ||
} | ||
|
||
const isDragging = this._mouseMoveTracker | ||
? this._mouseMoveTracker.isDragging() | ||
: false; | ||
|
||
// This function should only return flat values that can be compared quiclky | ||
// by `ReactComponentWithPureRenderMixin`. | ||
const state = { | ||
faceSize, | ||
isDragging, | ||
isHorizontal, | ||
position, | ||
scale, | ||
|
@@ -358,6 +346,8 @@ class Scrollbar extends React.PureComponent { | |
}; | ||
|
||
_onMouseDown = (/*object*/ event) => { | ||
this.setState({ isDragging: true }); | ||
|
||
/** @type {object} */ | ||
let nextState; | ||
|
||
|
@@ -387,7 +377,6 @@ class Scrollbar extends React.PureComponent { | |
nextState = {}; | ||
} | ||
|
||
nextState.focused = true; | ||
this._setNextState(nextState); | ||
|
||
this._mouseMoveTracker.captureMouseMoves(event); | ||
|
@@ -535,32 +524,6 @@ class Scrollbar extends React.PureComponent { | |
); | ||
}; | ||
|
||
_onFocus = () => { | ||
this.setState({ | ||
focused: true, | ||
}); | ||
}; | ||
|
||
_onBlur = () => { | ||
this.setState({ | ||
focused: false, | ||
}); | ||
}; | ||
|
||
_blur = () => { | ||
const el = ReactDOM.findDOMNode(this); | ||
if (!el) { | ||
return; | ||
} | ||
|
||
try { | ||
this._onBlur(); | ||
el.blur(); | ||
} catch (oops) { | ||
// pass | ||
} | ||
}; | ||
|
||
getTouchX = (/*object*/ e) => { | ||
return Math.round( | ||
e.targetTouches[0].clientX - e.target.getBoundingClientRect().x | ||
|
@@ -593,11 +556,6 @@ class Scrollbar extends React.PureComponent { | |
} | ||
return; | ||
} | ||
|
||
if (willScroll && _lastScrolledScrollbar !== this) { | ||
_lastScrolledScrollbar && _lastScrolledScrollbar._blur(); | ||
_lastScrolledScrollbar = this; | ||
} | ||
}; | ||
|
||
_didScroll = () => { | ||
|
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