Chrome scrollbar out of sync with height of long document #1086

Open
opened 2023-02-22 19:49:31 +01:00 by hubgit · 7 comments
hubgit commented 2023-02-22 19:49:31 +01:00 (Migrated from github.com)
### Describe the issue For as long as I can remember, it's been slightly difficult to scroll to the end of a long CM6 document in Chrome, as the scrollbar handle is out of sync with the document height. I recently noticed that neither Firefox or Safari have this problem, so maybe it's a Chrome bug? https://user-images.githubusercontent.com/14294/220729029-8f22d3d4-9e74-4f0c-b9ec-af0e8b505c08.mov ### Browser and platform Chrome, macOS ### Reproduction link https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBoZWxsbyBcbiIucmVwZWF0KDEwMDAwKSwKICBleHRlbnNpb25zOiBbCiAgICBiYXNpY1NldHVwLCAKICAgIGphdmFzY3JpcHQoKSwgCiAgICAvLyBFZGl0b3JWaWV3LmxpbmVXcmFwcGluZwogIF0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==
marijnh commented 2023-02-27 12:20:34 +01:00 (Migrated from github.com)

Chrome on Linux does not appear to have this issue. I guess your screenshot is from macOS? Maybe it's using the native scrollbar in some way that causes this. The height of the editor document will change as you scroll down (since the editor starts with an estimated height, and then measures the actual height of the content as it is drawn). It's possible Chrome on your platform is somehow not handling scroll height changes during a scrollbar drag correctly. That's probably not something CodeMirror can avoid.

Chrome on Linux does not appear to have this issue. I guess your screenshot is from macOS? Maybe it's using the native scrollbar in some way that causes this. The height of the editor document will change as you scroll down (since the editor starts with an estimated height, and then measures the actual height of the content as it is drawn). It's possible Chrome on your platform is somehow not handling scroll height changes during a scrollbar drag correctly. That's probably not something CodeMirror can avoid.
hubgit commented 2023-02-27 14:21:50 +01:00 (Migrated from github.com)

Correct, this is Chrome on macOS. I'll investigate further and see if there are any relevant issues already reported.

the editor starts with an estimated height, and then measures the actual height of the content as it is drawn

In the demo linked above, there's no line wrapping and no decorations, so all the lines have the same height, in which case I would expect that an estimated height based on the number of lines would be correct? That's just an aside though, this still needs to handle wrapped lines of varying sizes, so getting the initial height correct (if it isn't already) would only be a first step.

Correct, this is Chrome on macOS. I'll investigate further and see if there are any relevant issues already reported. > the editor starts with an estimated height, and then measures the actual height of the content as it is drawn In the demo linked above, there's no line wrapping and no decorations, so all the lines have the same height, in which case I would expect that an estimated height based on the number of lines would be correct? That's just an aside though, this still needs to handle wrapped lines of varying sizes, so getting the initial height correct (if it isn't already) would only be a first step.
marijnh commented 2023-02-27 16:18:33 +01:00 (Migrated from github.com)

Indeed, you are right—in this demo the estimated content height doesn't actually change during scrolling, so that's not it. Maybe something related to the somewhat large height of the scrolled content? I'll see if I can isolate the cause the next time I have my Apple laptop nearby.

Indeed, you are right—in this demo the estimated content height doesn't actually change during scrolling, so that's not it. Maybe something related to the somewhat large height of the scrolled content? I'll see if I can isolate the cause the next time I have my Apple laptop nearby.
hubgit commented 2023-02-27 22:21:33 +01:00 (Migrated from github.com)

Some more weird experimentation: in this demo, the scroll bar is incorrect, but if I remove one character from the line or reduce the number of lines by one then the scroll bar becomes correct. There seems to be a threshold at which the calculation becomes incorrect, for some reason.

Some more weird experimentation: in [this demo](https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKCm5ldyBFZGl0b3JWaWV3KHsKICAvLyByZW1vdmUgb25lIGggb3IgcmVkdWNlIHRoZSBudW1iZXIgb2YgbGluZXMgYnkgb25lCiAgZG9jOiAiaGhoaGhoaGhoaGhoaGhoaGhoaGhoXG4iLnJlcGVhdCg5MzQ5KSwKICBleHRlbnNpb25zOiBbCiAgICBiYXNpY1NldHVwLCAKICAgIGphdmFzY3JpcHQoKSwgCiAgICAvLyBFZGl0b3JWaWV3LmxpbmVXcmFwcGluZwogIF0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==), the scroll bar is incorrect, but if I remove one character from the line or reduce the number of lines by one then the scroll bar becomes correct. There seems to be a threshold at which the calculation becomes incorrect, for some reason.
marijnh commented 2023-02-28 10:41:56 +01:00 (Migrated from github.com)

I'm not getting this effect on macOS Chrome 110 for some reason. But maybe that's because I'm scrolling with a touchpad rather than a real mouse.

I'm not getting this effect on macOS Chrome 110 for some reason. But maybe that's because I'm scrolling with a touchpad rather than a real mouse.
hubgit commented 2023-02-28 11:32:55 +01:00 (Migrated from github.com)

Strange… I'm also using Chrome 110 and a MacBook touchpad.

A bit more experimenting: it seems to happen only at 100% and 200% page zoom, but not at any other zoom level I've tried, if I reload the page after changing the zoom level.

Strange… I'm also using Chrome 110 and a MacBook touchpad. A bit more experimenting: it seems to happen _only_ at 100% and 200% page zoom, but not at any other zoom level I've tried, if I reload the page after changing the zoom level.
rmmh commented 2025-11-07 00:54:32 +01:00 (Migrated from github.com)

This is also quite easy to reproduce by dragging the scroll bar on https://codemirror.net/examples/million/ up and down

This is also quite easy to reproduce by dragging the scroll bar on https://codemirror.net/examples/million/ up and down
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/dev#1086
No description provided.