-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(editor): restore cursor position after tag/env-var completion in code editors #3406
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b3d3312
fix(editor): restore cursor position after tag/env-var completion in …
waleedlatif1 3983524
lint
waleedlatif1 a47d64e
refactor(editor): extract restoreCursorAfterInsertion helper, fix wea…
waleedlatif1 0983950
updated
waleedlatif1 b9882c7
fix(editor): replace useEffect with direct ref assignment for editorV…
waleedlatif1 a651923
fix(editor): guard cursor restoration behind preview/readOnly check
waleedlatif1 f37f92b
fix(editor): escape blockId in CSS selector with CSS.escape()
waleedlatif1 167f64c
perf(editor): use ref for cursor fallback to stabilize useCallback
waleedlatif1 a73bd6c
refactor(editor): pass cursor position explicitly from dropdowns
waleedlatif1 d3e7186
docs(editor): fix JSDoc terminology — macrotask not microtask
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...im/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Restores the cursor position in a textarea after a dropdown insertion. | ||
| * Schedules a macrotask (via setTimeout) that runs after React's controlled-component commit | ||
| * so that the cursor position sticks. | ||
| * | ||
waleedlatif1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @param textarea - The textarea element to restore cursor in (may be null) | ||
| * @param newCursorPosition - The exact position to place the cursor at | ||
| */ | ||
| export function restoreCursorAfterInsertion( | ||
| textarea: HTMLTextAreaElement | null, | ||
| newCursorPosition: number | ||
| ): void { | ||
| setTimeout(() => { | ||
| if (textarea) { | ||
| textarea.focus() | ||
| textarea.selectionStart = newCursorPosition | ||
| textarea.selectionEnd = newCursorPosition | ||
| } | ||
| }, 0) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.