Skip to content

Commit 87f812b

Browse files
authored
Merge pull request #1001 from senithkay/fix-helper-pane-misalignment
fix helper pane overflow from editor right when opened through toggle button
2 parents ba5b5a7 + f9923f4 commit 87f812b

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/CodeUtils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
getTokenTypeColor,
3333
getChipDisplayContent
3434
} from "./chipStyles";
35+
import { HELPER_PANE_WIDTH } from "./constants";
3536

3637
export type TokenStream = number[];
3738

@@ -443,7 +444,6 @@ export const buildOnFocusListner = (onTrigger: (cursor: CursorInfo) => void) =>
443444
let relativeTop = coords.bottom - editorRect.top + 5;
444445
let relativeLeft = coords.left - editorRect.left;
445446

446-
const HELPER_PANE_WIDTH = 300;
447447
const editorWidth = editorRect.width;
448448
const relativeRight = relativeLeft + HELPER_PANE_WIDTH;
449449
const overflow = relativeRight - editorWidth;
@@ -477,7 +477,6 @@ export const buildOnSelectionChange = (onTrigger: (cursor: CursorInfo) => void)
477477
let relativeTop = coords.bottom - editorRect.top + 5;
478478
let relativeLeft = coords.left - editorRect.left;
479479

480-
const HELPER_PANE_WIDTH = 300;
481480
const editorWidth = editorRect.width;
482481
const relativeRight = relativeLeft + HELPER_PANE_WIDTH;
483482
const overflow = relativeRight - editorWidth;
@@ -548,7 +547,6 @@ export const buildOnChangeListner = (onTrigeer: (newValue: string, cursor: Curso
548547
let relativeTop = coords.bottom - editorRect.top + 5;
549548
let relativeLeft = coords.left - editorRect.left;
550549

551-
const HELPER_PANE_WIDTH = 300;
552550
const editorWidth = editorRect.width;
553551
const relativeRight = relativeLeft + HELPER_PANE_WIDTH;
554552
const overflow = relativeRight - editorWidth;

workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/components/ChipExpressionEditor.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import FXButton from "./FxButton";
4949
import { HelperPaneToggleButton } from "./HelperPaneToggleButton";
5050
import { HelperPane } from "./HelperPane";
5151
import { listContinuationKeymap } from "../../../ExpandedEditor/utils/templateUtils";
52+
import { HELPER_PANE_WIDTH } from "../constants";
5253

5354
type HelperPaneState = {
5455
isOpen: boolean;
@@ -245,11 +246,10 @@ export const ChipExpressionEditorComponent = (props: ChipExpressionEditorCompone
245246
let top = buttonRect.bottom - editorRect.top;
246247
let left = buttonRect.left - editorRect.left;
247248

248-
// Add overflow correction for window boundaries
249-
const HELPER_PANE_WIDTH = 300;
250-
const viewportWidth = window.innerWidth;
251-
const absoluteLeft = buttonRect.left;
252-
const overflow = absoluteLeft + HELPER_PANE_WIDTH - viewportWidth;
249+
// Add overflow correction for editor boundaries
250+
const editorWidth = editorRect.width;
251+
const relativeRight = left + HELPER_PANE_WIDTH;
252+
const overflow = relativeRight - editorWidth;
253253

254254
if (overflow > 0) {
255255
left -= overflow;

workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
export const CHIP_EXPRESSION_EDITOR_HEIGHT = 26;
2020
export const EXPANDED_EDITOR_HEIGHT = 500;
21+
export const HELPER_PANE_WIDTH = 300;
2122

2223
// Data attributes
2324
export const DATA_CHIP_ATTRIBUTE = 'data-chip';

0 commit comments

Comments
 (0)