Skip to content

fix: hide per-line scrollbars of unwrapped code blocks in editing mode - #189

Merged
mugiwara85 merged 1 commit into
mugiwara85:masterfrom
hkawase:fix/hide-unwrapped-line-scrollbars
Nov 22, 2026
Merged

mugiwara85 merged 1 commit into
mugiwara85:masterfrom
hkawase:fix/hide-unwrapped-line-scrollbars

Conversation

@hkawase

@hkawase hkawase commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

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-scrollbar styles on an element whose scrollbar-color or scrollbar-width is not auto. Obsidian 1.15.1 sets scrollbar-color on body:not(.styled-scrollbars) (the default on macOS), and every line inherits it, so the rule has no effect.

Fix

Add scrollbar-width: none to .codeblock-customizer-nowrap lines. The ::-webkit-scrollbar rule is kept for older versions. The block-level scrollbar (.codeblock-customizer-scrollbar) is not affected.

Screenshots

Before:

before

After:

after

Testing

  • macOS, Obsidian 1.15.1, master (8cc7e84) + this change: the per-line scrollbars are gone; trackpad horizontal scrolling still works and stays in sync across lines; the scrollbar below the block is still shown.
  • npm test: 109 passed. stylelint passes.

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.
@mugiwara85

Copy link
Copy Markdown
Owner

@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.

@mugiwara85

Copy link
Copy Markdown
Owner

@hkawase Also please could you try it, that if you take the current main.js and styles.css and replace the ones in your vault with the newest, the same thing happens? I already fixed a lot of smaller bugs, maybe this one is also fixed (just net yet released)

@hkawase

hkawase commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@mugiwara85 Thanks for checking!

  • Theme / custom CSS: none. I reproduced it in a fresh vault with the default theme, no CSS snippets, and Codeblock Customizer as the only plugin.
  • Latest build: yes. The "before" screenshot was taken with main.js and styles.css from the current master (8cc7e84), not 1.4.7.

I think this only happens on macOS. Obsidian adds the styled-scrollbars class to body on every platform except macOS, and its app CSS has:

body:not(.styled-scrollbars) { scrollbar-color: var(--scrollbar-thumb-bg) var(--scrollbar-bg); }

So on macOS every element inherits a non-auto scrollbar-color, and Chromium then ignores ::-webkit-scrollbar on those elements, including the display: none rule for unwrapped lines. On Windows/Linux the class is present, so ::-webkit-scrollbar works as intended and only the scrollbar below the block is shown.

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 document.body.addClass("styled-scrollbars") with the current master makes the per-line scrollbars disappear.

Environment: macOS, Obsidian 1.15.1.

@mugiwara85

Copy link
Copy Markdown
Owner

@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!

@mugiwara85
mugiwara85 merged commit d4089bf into mugiwara85:master Nov 22, 2026
1 check passed
@mugiwara85

Copy link
Copy Markdown
Owner

@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 main.js and styles.css.
Thanks for the PR!

@hkawase

hkawase commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging and for the quick fix on the bottom scrollbar! I'll try the latest build. Looking forward to the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants