Repository navigation
fix: hide per-line scrollbars of unwrapped code blocks in editing mode - #189
Conversation
Chromium ignores ::-webkit-scrollbar styles when scrollbar-color or scrollbar-width is not auto. Obsidian sets scrollbar-color on body:not(.styled-scrollbars), which every line inherits, so the per-line scrollbars of unwrapped code blocks were still shown. Add scrollbar-width: none to hide them.
|
@hkawase Thanks for the PR, but I am a little surprised, that for you it is displayed like that? I mean that every line has a scrollbar. Only the last line supposed to have one, which makes unfortunately the PR incorrect. Could you please tell me which theme are you using? Also do you use any custom CSS? Maybe one of them overwrites the expected behavior. I could track it down and fix it. |
|
@hkawase Also please could you try it, that if you take the current |
|
@mugiwara85 Thanks for checking!
I think this only happens on macOS. Obsidian adds the body:not(.styled-scrollbars) { scrollbar-color: var(--scrollbar-thumb-bg) var(--scrollbar-bg); }So on macOS every element inherits a non- To reproduce it on Windows/Linux, run this in the developer console and look at an unwrapped code block in Live Preview: document.body.removeClass("styled-scrollbars")I also confirmed it the other way around: on macOS, running Environment: macOS, Obsidian 1.15.1. |
|
@hkawase Thanks for the detailed feedback. I was not aware that there are differences on MacOS, because Obsidian supposed to work the same way. Anyway I have a Mac lying around currently, so I can test it. Thanks for the info. I'll check it out and get back to you! |
|
@hkawase I check it. There was one additional CSS required so the last scrollbar is shown. It works on Mac as well now. You can try it, if you copy the current |
|
Thanks for merging and for the quick fix on the bottom scrollbar! I'll try the latest build. Looking forward to the next release. |
Problem
In editing mode (Live Preview), a horizontal scrollbar is shown under every line of an unwrapped code block.
Each line is meant to hide its own scrollbar with
::-webkit-scrollbar { display: none; }. However, Chromium ignores::-webkit-scrollbarstyles on an element whosescrollbar-colororscrollbar-widthis notauto. Obsidian 1.15.1 setsscrollbar-coloronbody:not(.styled-scrollbars)(the default on macOS), and every line inherits it, so the rule has no effect.Fix
Add
scrollbar-width: noneto.codeblock-customizer-nowraplines. The::-webkit-scrollbarrule is kept for older versions. The block-level scrollbar (.codeblock-customizer-scrollbar) is not affected.Screenshots
Before:
After:
Testing
npm test: 109 passed.stylelintpasses.