make expression mode default in record editor#1546
Conversation
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
workspaces/ballerina/ballerina-side-panel/src/components/editors/FieldFactory.tsx
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
Approach
Summary by CodeRabbit