Skip to content

Fix notebook scrolling in web mode#13558

Merged
nstrayer merged 4 commits into
mainfrom
fix/notebook-scroll-web-mode
May 14, 2026
Merged

Fix notebook scrolling in web mode#13558
nstrayer merged 4 commits into
mainfrom
fix/notebook-scroll-web-mode

Conversation

@nstrayer
Copy link
Copy Markdown
Contributor

@nstrayer nstrayer commented May 14, 2026

In web-hosted Positron the workbench's monaco-scrollable-element ancestor calls preventDefault() on wheel events during the bubble phase, which blocks native scrolling on the notebook cells container. In Electron this doesn't manifest because the workbench's ScrollableElement short-circuits when it detects it has nothing to scroll.

This PR fixes this by adding a stopPropagation() on wheel events at the cells container boundary so they never reach the workbench handler, restoring native overflow: auto scrolling in web mode. Applied unconditionally since it's harmless in Electron (the ancestor already skips preventDefault when it has no overflow).

References

Root cause:

  • src/vs/workbench/browser/window.ts:271 -- the BrowserWindow wheel listener that calls preventDefault() on all wheel events on mainContainer. Only exists in web build.
  • src/vs/workbench/electron-browser/window.ts:84 -- NativeWindow (Electron equivalent) has no wheel handler, which is why this only affects web mode.

Why CSS alone can't fix it:

  • src/vs/workbench/browser/media/style.css:70-73 -- .monaco-workbench.web already has overscroll-behavior: none, but that only prevents scroll-chaining, not preventDefault() canceling native scroll.

The fix (stopPropagation pattern):

  • src/vs/workbench/contrib/positronNotebook/browser/PositronNotebookComponent.tsx:106-119 -- the fix itself
  • src/vs/workbench/contrib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.tsx:190-196 -- same pattern already in use for the same reason, with a comment linking to the root cause

Scroll mechanics for context:

  • src/vs/base/browser/ui/scrollbar/scrollableElement.ts:424 -- ScrollableElement registers with { passive: false } (same mechanism the workbench listener uses to block scrolling)
  • src/vs/workbench/contrib/positronNotebook/browser/PositronNotebookComponent.css:101 -- the cells container uses native overflow: auto

Release Notes

New Features

  • N/A

Bug Fixes

  • Fix Positron notebook scrolling broken in web mode (PWB)

Validation Steps

@:positron-notebooks @:web

  1. Open Positron in web mode (PWB)
  2. Open or create a notebook with enough cells to overflow the viewport
  3. Scroll with the mouse wheel/trackpad -- cells container should scroll normally
  4. Verify scrolling still works in Electron mode (no regression)

nstrayer added 3 commits May 14, 2026 14:33
In web-hosted Positron, the monaco-workbench element's wheel event
listener calls preventDefault() during the bubble phase, which blocks
native scrolling on the notebook cells container. In Electron this
doesn't occur because the workbench's ScrollableElement short-circuits
when it has nothing to scroll.

Add stopPropagation() on wheel events at the cells container so they
never reach the workbench handler, restoring native overflow:auto
scrolling in web mode.
Explain why the handler runs unconditionally (harmless in Electron)
and why the empty dependency array is safe (container DOM node is
stable for the component lifetime).
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:positron-notebooks @:web

readme  valid tags

The previous comment incorrectly attributed the behavior to a
ScrollableElement short-circuit. The real cause is BrowserWindow
(window.ts:271) registering an unconditional preventDefault() on all
wheel events on mainContainer to block macOS back/forward gestures.
This listener only exists in the web build; NativeWindow (Electron)
has no wheel handler at all.
@nstrayer nstrayer requested a review from dhruvisompura May 14, 2026 19:25
Copy link
Copy Markdown
Contributor

@dhruvisompura dhruvisompura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix worked for me on a web build!

@nstrayer nstrayer merged commit 6fb2287 into main May 14, 2026
20 of 22 checks passed
@nstrayer nstrayer deleted the fix/notebook-scroll-web-mode branch May 14, 2026 20:11
@github-actions github-actions Bot locked and limited conversation to collaborators May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants