-
Notifications
You must be signed in to change notification settings - Fork 59
[BI Data Mapper] Fix expression bar focussing issues #998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BI Data Mapper] Fix expression bar focussing issues #998
Conversation
WalkthroughThe ExpressionEditor API gains a new imperative Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DataMapper as ExpressionBar
participant Input as TextField/InputElement
participant Editor as ExpressionEditor
User->>DataMapper: Selects input port (expression bar focused)
DataMapper->>Input: read selectionStart (cursorPos)
Note right of DataMapper `#DCEFFB`: OLD used shadowRoot-based cursor lookup
Note right of DataMapper `#BEE7A5`: NEW uses inputElement.selectionStart
DataMapper->>Input: Insert generated expression at cursorPos
DataMapper->>Editor: handleChange(updatedText)
DataMapper->>Input: set cursor to cursorPos + insertedLength
DataMapper->>DataMapper: resetInputPort()
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
workspaces/ballerina/data-mapper/src/components/DataMapper/Header/ExpressionBar.tsx (1)
215-215: Use consistent inputElement access pattern.Line 215 still uses the shadowRoot approach (
textFieldRef.current.shadowRoot.querySelector('input').selectionStart), while line 116 uses the cleanerinputElementAPI. For consistency and maintainability, use the same pattern throughout the file.Apply this diff to align with the new pattern:
- const cursorPosition = textFieldRef.current.shadowRoot.querySelector('input').selectionStart; + const cursorPosition = textFieldRef.current.inputElement?.selectionStart ?? 0; triggerCompletions(outputId, viewId, textFieldValue, cursorPosition);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
workspaces/ballerina/data-mapper/src/components/DataMapper/Header/ExpressionBar.tsx(2 hunks)workspaces/common-libs/ui-toolkit/src/components/ExpressionEditor/components/Header/ExpressionEditor.tsx(3 hunks)workspaces/common-libs/ui-toolkit/src/components/ExpressionEditor/types/header.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-20T06:44:07.498Z
Learnt from: KCSAbeywickrama
Repo: wso2/vscode-extensions PR: 969
File: workspaces/ballerina/data-mapper/src/components/Diagram/utils/node-utils.ts:23-44
Timestamp: 2025-11-20T06:44:07.498Z
Learning: In the data mapper node-utils.ts, when `lastViewIndex == 0`, the code is at the root view and should NOT use `focusInputRootMap` for fallback input node resolution. The truthiness check on `lastViewIndex` is intentional to skip the fallback at the root level.
Applied to files:
workspaces/ballerina/data-mapper/src/components/DataMapper/Header/ExpressionBar.tsx
🧬 Code graph analysis (2)
workspaces/common-libs/ui-toolkit/src/components/ExpressionEditor/components/Header/ExpressionEditor.tsx (1)
workspaces/common-libs/ui-toolkit/src/components/Codicon/Codicon.tsx (1)
Codicon(44-56)
workspaces/ballerina/data-mapper/src/components/DataMapper/Header/ExpressionBar.tsx (1)
workspaces/ballerina/data-mapper/src/components/Diagram/utils/modification-utils.ts (1)
buildInputAccessExpr(205-220)
🔇 Additional comments (4)
workspaces/common-libs/ui-toolkit/src/components/ExpressionEditor/types/header.ts (1)
25-25: LGTM! Clean API extension for cursor control.The new
setCursormethod provides a straightforward way for external components to programmatically position the cursor, which aligns with the PR objective of inserting expressions at the current cursor position.workspaces/common-libs/ui-toolkit/src/components/ExpressionEditor/components/Header/ExpressionEditor.tsx (2)
340-342: LGTM! Correct implementation of the new setCursor API.The imperative handle method correctly delegates to the existing
setCursorutility and is properly exposed throughuseImperativeHandle.Also applies to: 382-382
427-444: LGTM! Prevents focus loss when closing completions.Wrapping the close button with
onMouseDownpreventDefault ensures the input field retains focus when the user clicks the close button, addressing the focus-loss issue mentioned in the PR description.workspaces/ballerina/data-mapper/src/components/DataMapper/Header/ExpressionBar.tsx (1)
108-137: Verify effect dependencies and correctness.The effect uses
focusedPort,focusedFilter, andtextFieldValue(lines 114, 123) but only lists[inputPort]as a dependency. While the gating conditional on line 114 may make this intentional, please verify that stale closures won't cause issues whenfocusedPort/focusedFilterchange betweeninputPortupdates.Additionally, the PR objectives mention restoring undo functionality (both undo icon and keyboard shortcut Ctrl+Z), but I don't see undo-related changes in this PR. Please confirm whether this objective is addressed elsewhere or if additional changes are needed.
Purpose
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.