Skip to content

Comments

make expression mode default in record editor#1546

Merged
kanushka merged 1 commit intowso2:release/bi-1.8.xfrom
senithkay:make-expression-mode-default-in-record-config
Feb 24, 2026
Merged

make expression mode default in record editor#1546
kanushka merged 1 commit intowso2:release/bi-1.8.xfrom
senithkay:make-expression-mode-default-in-record-config

Conversation

@senithkay
Copy link
Contributor

@senithkay senithkay commented Feb 24, 2026

Purpose

Currently, in fields where both Record Editor mode and Expression mode are available, the default selected mode is Record Editor mode.

This does not align well with common developer workflows where expressions are frequently used. As a result, users must manually switch to Expression mode each time they configure such fields, creating unnecessary friction and reducing efficiency.

This PR updates the default behavior to better support expression-driven configurations.

Resolves: wso2/product-ballerina-integrator#2566


Goals

  • Change the default selected mode from Record Editor mode to Expression mode in all applicable fields.
  • Preserve the ability to switch to Record Editor mode using the existing mode switcher.
  • Ensure consistent behavior across all relevant form fields.

Approach

  • Updated the default mode configuration in fields that support both Record Editor and Expression modes.
  • Set Expression mode as the initial selected state during form initialization.
  • Ensured that the mode switcher continues to function correctly and allows seamless switching to Record Editor mode.
  • Verified that:
    • Existing values load correctly in Expression mode.
    • Switching between modes preserves field state.
  • Manually tested multiple nodes and scenarios where record editor support is available to confirm consistent behavior.

Summary by CodeRabbit

  • Refactor
    • Simplified field editing logic by removing unnecessary state tracking and streamlining the mode selection flow for improved reliability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

The change simplifies field mode selection logic in the Record Editor by removing a dirty flag mechanism and unconditionally computing the initial mode based on current field types, reducing state tracking complexity.

Changes

Cohort / File(s) Summary
Mode Selection Simplification
workspaces/ballerina/ballerina-side-panel/src/components/editors/FieldFactory.tsx
Removed isModeSelectionDirty useRef tracking and conditional logic. Initial mode setup now occurs unconditionally based on field types. handleModeChange simplified to directly call setInputMode and updateFieldTypesSelection without mutating state flags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 With whiskers twitched and hoppy delight,
We've trimmed the branches, made logic tight—
No dirty flags to slow us down,
Expression mode's the talk of town!
Cleaner flows make hearts so bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making expression mode the default in the record editor.
Description check ✅ Passed The PR description addresses Purpose, Goals, and Approach sections with clear details, though it doesn't follow the full template structure with sections like UI Component Development, Automation tests, and Security checks.
Linked Issues check ✅ Passed The code changes successfully implement the objective: removing isModeSelectionDirty flag and defaulting to expression mode initialization, directly addressing issue #2566's requirement to make Expression mode the default.
Out of Scope Changes check ✅ Passed All changes in FieldFactory.tsx are directly related to implementing the default expression mode behavior specified in issue #2566, with no extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@workspaces/ballerina/ballerina-side-panel/src/components/editors/FieldFactory.tsx`:
- Around line 120-128: The effect currently always reinitializes rendering types
and inputMode (calls setRenderingEditors, getInitialSelectedInputType,
getInputModeFromTypes, setInputMode, updateFieldTypesSelection) whenever
props.field or props.recordTypeFields change, which resets a user-selected mode;
modify the effect to only perform this initialization on first render or when
the field identity/key changes (e.g., compare props.field.id or a stable
fieldKey) or introduce a user-dirty flag that, once set when the user toggles
mode, prevents overwriting inputMode; if the field identity changes, re-run the
full initialization (setRenderingEditors and setInputMode), otherwise skip
setInputMode/updateFieldTypesSelection to preserve the user selection.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebf8a66 and 641a040.

📒 Files selected for processing (1)
  • workspaces/ballerina/ballerina-side-panel/src/components/editors/FieldFactory.tsx

@kanushka kanushka merged commit e91c9f0 into wso2:release/bi-1.8.x Feb 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants