Skip to content

Commit f304b1b

Browse files
authored
Merge pull request #1352 from senithkay/fix-record-config-helper-overflow
Fix record config helper overflow from the model
2 parents 16b93ec + eb31b14 commit f304b1b

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ export class ChipExpressionEditorDefaultConfiguration {
4747
getIsValueCompatible(value: string): boolean {
4848
return true;
4949
}
50+
51+
getIsToggleHelperAvailable(): boolean {
52+
return true;
53+
}
5054
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ export const ChipExpressionEditorComponent = (props: ChipExpressionEditorCompone
476476

477477
return (
478478
<>
479-
{showToggle && (
479+
{showToggle && configuration.getIsToggleHelperAvailable() && (
480480
<HelperPaneToggleButton
481481
ref={helperPaneToggleButtonRef}
482482
isOpen={helperPaneState.isOpen}
@@ -512,7 +512,7 @@ export const ChipExpressionEditorComponent = (props: ChipExpressionEditorCompone
512512
}
513513
{!props.disabled && (
514514
<FloatingButtonContainer>
515-
{!props.isExpandedVersion &&
515+
{!props.isExpandedVersion && configuration.getIsToggleHelperAvailable() &&
516516
<FloatingToggleButton
517517
ref={helperPaneToggleButtonRef}
518518
onClick={handleManualToggle}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export const detectTokenPatterns = (
311311
return compounds;
312312
};
313313

314-
// Calculates helper pane position with viewport overflow correction
314+
// Calculates helper pane position with editor right boundary overflow correction
315315
export const calculateHelperPanePosition = (
316316
targetCoords: { bottom: number; left: number },
317317
editorRect: DOMRect,
@@ -322,10 +322,10 @@ export const calculateHelperPanePosition = (
322322
let top = targetCoords.bottom - editorRect.top + scrollTop;
323323
let left = targetCoords.left - editorRect.left;
324324

325-
// Add overflow correction for window boundaries
326-
const viewportWidth = window.innerWidth;
327-
const absoluteLeft = targetCoords.left;
328-
const overflow = absoluteLeft + helperPaneWidth - viewportWidth;
325+
// Add overflow correction for editor right boundary
326+
const editorRight = editorRect.left + editorRect.width;
327+
const paneRight = targetCoords.left + helperPaneWidth;
328+
const overflow = paneRight - editorRight;
329329

330330
if (overflow > 0) {
331331
left -= overflow;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,9 @@ export class NumberExpressionEditorConfig extends ChipExpressionEditorDefaultCon
216216
return this.DECIMAL_INPUT_REGEX.test(value);
217217
}
218218
}
219+
220+
export class RecordConfigExpressionEditorConfig extends ChipExpressionEditorDefaultConfiguration {
221+
getIsToggleHelperAvailable(): boolean {
222+
return false;
223+
}
224+
}

workspaces/ballerina/ballerina-visualizer/src/views/BI/HelperPaneNew/Views/RecordConfigModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import styled from "@emotion/styled";
2222
import { useEffect, useRef, useState, RefObject } from "react";
2323
import { useRpcContext } from "@wso2/ballerina-rpc-client";
2424
import { RecordConfigView } from "./RecordConfigView";
25-
import { ChipExpressionEditorComponent, Context as FormContext, HelperpaneOnChangeOptions, FieldProvider, FormField, FormExpressionEditorProps, getPropertyFromFormField } from "@wso2/ballerina-side-panel";
25+
import { ChipExpressionEditorComponent, Context as FormContext, HelperpaneOnChangeOptions, FieldProvider, FormField, FormExpressionEditorProps, getPropertyFromFormField, RecordConfigExpressionEditorConfig } from "@wso2/ballerina-side-panel";
2626
import { useForm } from "react-hook-form";
2727
import { debounce } from "lodash";
2828
import ReactMarkdown from "react-markdown";
@@ -704,7 +704,7 @@ export function ConfigureRecordPage(props: ConfigureRecordPageProps) {
704704
extractArgsFromFunction={wrappedExtractArgsFromFunction}
705705
getHelperPane={wrappedGetHelperPane}
706706
sx={{ height: "350px" }}
707-
configuration={new ChipExpressionEditorDefaultConfiguration()}
707+
configuration={new RecordConfigExpressionEditorConfig()}
708708
isExpandedVersion={false}
709709
/>
710710
{formDiagnostics && formDiagnostics.length > 0 && (

0 commit comments

Comments
 (0)