Skip to content

Commit 54cbc06

Browse files
authored
Fix scrolling in variables view for web (#5513)
1 parent acff147 commit 54cbc06

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/vs/workbench/contrib/positronVariables/browser/components/variablesInstance.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'vs/css!./variablesInstance';
77
import * as React from 'react';
88
import { KeyboardEvent, useEffect, useRef, useState } from 'react'; // eslint-disable-line no-duplicate-imports
99
import * as DOM from 'vs/base/browser/dom';
10-
import { isMacintosh } from 'vs/base/common/platform';
10+
import { isMacintosh, isWeb } from 'vs/base/common/platform';
1111
import { DisposableStore } from 'vs/base/common/lifecycle';
1212
import { useStateRef } from 'vs/base/browser/ui/react/useStateRef';
1313
import { FixedSizeList as List, ListChildComponentProps } from 'react-window';
@@ -448,6 +448,15 @@ export const VariablesInstance = (props: VariablesInstanceProps) => {
448448
positronVariablesContext.reactComponentContainer.focusChanged?.(false);
449449
};
450450

451+
// workaround for web disabling scrolling on the window to prevent URL navigation
452+
const wheelHandler = (e: React.WheelEvent<HTMLDivElement>) => {
453+
if (!isWeb) {
454+
return;
455+
}
456+
457+
innerRef.current.parentElement?.scrollBy(e.deltaX, e.deltaY);
458+
};
459+
451460
/**
452461
* VariableEntry component.
453462
* @param index The index of the variable entry.
@@ -523,6 +532,7 @@ export const VariablesInstance = (props: VariablesInstanceProps) => {
523532
onKeyDown={keyDownHandler}
524533
onFocus={focusHandler}
525534
onBlur={blurHandler}
535+
onWheel={wheelHandler}
526536
>
527537
{!variableEntries.length ?
528538
<VariablesEmpty initializing={initializing} /> :

0 commit comments

Comments
 (0)