-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Scrolling with mouse fails past 5.9.1 when CSS alters inner div width of scrollbar. #3677
Comments
Well our analysis was all wrong. If we get lucky, then
in NativeScrollbars update(), and we never call the If we get unlucky then these values start as zero, and we set pointerEvents="none" then don't recover. Every time we switch files in our tool we are unlucky :-( |
I dug in to this further. Note that our results vary if we stop on Chrome Devtools breakpoints. We seem to go through a state where
So if we could avoid triggering the zeroWidthHack() or if we could have I'd love to have a simple reproduction, but it seems hard. For now we set
|
I'd like to get to the bottom of this, but without a test case that reproduces the problem, I really don't know where to look. I double-checked that if the editor starts off invisible, it still does the right thing. You seem to somehow end up with a situation where your editor does have dimensions, but your scrollbar width still comes out as zero. I couldn't find a way to produce such a situation. |
With
That results in clientHeight 0, sWidth 12.
That results in clientHeight 0 sWidth 0. function wrappingChanged(cm) {
if (cm.options.lineWrapping) {
addClass(cm.display.wrapper, "CodeMirror-wrap");
cm.display.sizer.style.minWidth = "";
cm.display.sizerWidth = null
} else {
rmClass(cm.display.wrapper, "CodeMirror-wrap");
findMaxLine(cm)
}
estimateLineHeights(cm);
regChange(cm);
clearCaches(cm);
setTimeout(function() {
updateScrollbars(cm)
}, 100)
} And the updateScrollbars call here changes clientHeight to 594 while sWidth remains 0. Does this help? |
The way |
CodeMirror issues codemirror/codemirror5#3677
With CodeMirror past 5.9.1 we lost the ability to scroll with the mouse in our use of CodeMirror.
We trace this issue to
https://google.com/url?sa=D&q=https%3A%2F%2Fgithub.com%2Fcodemirror%2FCodeMirror%2Fcommit%2Fa11ccbefa281a0e728b7431ba52f550854831ea6
where these lines:
seem to assume that the scrollbar has an inner div only one pixel wide (the
1
in theelt
computation).When our scroll bar renders, the
div
inside of.CodeMirror-vscrollbar
comes out 6px wide:Thus
elt
points to the innerdiv
andelt != bar
, disabling thepointerEvents
.At least part of the width was caused by a CSS rule like
but, this being CSS, removing the 12px width reduced the inner div from 6px to 3px, not 12px to 1px.
We worked around the issue by adding a CSS rule to set the
maxWidth: 1px
on the innerdiv
. We'd love to not have to do that!The text was updated successfully, but these errors were encountered: