Skip to content

Commit

Permalink
Fix scrolling in variables view for web (#5513)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtmok authored Nov 26, 2024
1 parent acff147 commit 54cbc06
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'vs/css!./variablesInstance';
import * as React from 'react';
import { KeyboardEvent, useEffect, useRef, useState } from 'react'; // eslint-disable-line no-duplicate-imports
import * as DOM from 'vs/base/browser/dom';
import { isMacintosh } from 'vs/base/common/platform';
import { isMacintosh, isWeb } from 'vs/base/common/platform';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { useStateRef } from 'vs/base/browser/ui/react/useStateRef';
import { FixedSizeList as List, ListChildComponentProps } from 'react-window';
Expand Down Expand Up @@ -448,6 +448,15 @@ export const VariablesInstance = (props: VariablesInstanceProps) => {
positronVariablesContext.reactComponentContainer.focusChanged?.(false);
};

// workaround for web disabling scrolling on the window to prevent URL navigation
const wheelHandler = (e: React.WheelEvent<HTMLDivElement>) => {
if (!isWeb) {
return;
}

innerRef.current.parentElement?.scrollBy(e.deltaX, e.deltaY);
};

/**
* VariableEntry component.
* @param index The index of the variable entry.
Expand Down Expand Up @@ -523,6 +532,7 @@ export const VariablesInstance = (props: VariablesInstanceProps) => {
onKeyDown={keyDownHandler}
onFocus={focusHandler}
onBlur={blurHandler}
onWheel={wheelHandler}
>
{!variableEntries.length ?
<VariablesEmpty initializing={initializing} /> :
Expand Down

0 comments on commit 54cbc06

Please sign in to comment.