[Bugfix:InstructorUI] Fix missing cursor in config editor#12554
Conversation
… tab When the CodeMirror editor is initialized for the autograding config editor, the cursor is not visible because the editor is not focused after creation. This is especially problematic since the editor lives inside a dynamically toggled container that starts hidden. Add refresh() to recalculate layout after the editor is rendered in the previously-hidden container, and focus() to place the blinking cursor at the beginning of the document. Fixes: cursor not visible when clicking to edit config.json in the Edit Gradeable > Submission/Autograding tab.
|
I’ve tested these changes locally, but unfortunately, I'm still seeing the original issue on my system. @Aditya060806, could you double-check if it solves the issue? |
|
@williamjallen I looked at both PRs, but I think #12554 is actually tackling the wrong problem. That approach would work if the issue were the editor's size/geometry, but the bug is just a color contrast issue. The cursor is actually there; it's just invisible because it's inheriting a color that matches the background. My PR #12552 fixes this directly by setting the color. It's a much simpler fix and avoids changing the editor's logic when we only need a style change. |
roye2
left a comment
There was a problem hiding this comment.
The changes to the code are simple and refreshing the cursor through codemirror is the correct approach. I tested the changes in the editor on my VM in Light and Dark mode and they work as intended.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12554 +/- ##
=========================================
Coverage 21.66% 21.66%
Complexity 9637 9637
=========================================
Files 268 268
Lines 36222 36222
Branches 487 487
=========================================
Hits 7847 7847
Misses 27892 27892
Partials 483 483
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…2554) ## Description Fixes the missing blinking cursor in the autograding configuration editor on the Edit Gradeable > Submission/Autograding tab. When a file (e.g., \config.json\) is clicked in the file tree to open it in the CodeMirror editor, no cursor is visible. The user can type and edit, but there is no visual indicator of the cursor position, making editing difficult and confusing. ### Root Cause The CodeMirror instance is created inside a container (\#gradeable-config-structure\) that starts with \display: none\ and is toggled open dynamically. When \CodeMirror.fromTextArea()\ runs: 1. The editor does not automatically receive focus, so no blinking cursor is shown. 2. The editor may miscalculate its layout because it was initialized in a previously-hidden container. ### Fix Added two calls after CodeMirror initialization in \loadCodeMirror()\: - **\codeMirrorInstance.refresh()\** — Forces CodeMirror to recalculate its layout so the cursor renders at the correct position. - **\codeMirrorInstance.focus()\** — Gives the editor focus and places a blinking cursor at the beginning of the document. Since \ eloadCodeMirror()\ (used by toggle line numbers / tab size settings) calls \loadCodeMirror()\ internally, the fix applies to both initial file loading and editor setting changes. ### Testing 1. Go to any Edit Gradeable page 2. Click the **Submission/Autograding** tab 3. Select an uploaded autograding configuration 4. Click **Open Editor** 5. Click on \config.json\ (or any file) in the file tree 6. ✅ A blinking cursor appears at the beginning of the document 7. Click within the text → cursor moves to clicked position 8. Toggle line numbers / tab size → cursor remains visible after reload 9. Switch between files → cursor appears for each newly loaded file Closes Submitty#12551 Co-authored-by: Emma Roy <[email protected]>
…2554) ## Description Fixes the missing blinking cursor in the autograding configuration editor on the Edit Gradeable > Submission/Autograding tab. When a file (e.g., \config.json\) is clicked in the file tree to open it in the CodeMirror editor, no cursor is visible. The user can type and edit, but there is no visual indicator of the cursor position, making editing difficult and confusing. ### Root Cause The CodeMirror instance is created inside a container (\#gradeable-config-structure\) that starts with \display: none\ and is toggled open dynamically. When \CodeMirror.fromTextArea()\ runs: 1. The editor does not automatically receive focus, so no blinking cursor is shown. 2. The editor may miscalculate its layout because it was initialized in a previously-hidden container. ### Fix Added two calls after CodeMirror initialization in \loadCodeMirror()\: - **\codeMirrorInstance.refresh()\** — Forces CodeMirror to recalculate its layout so the cursor renders at the correct position. - **\codeMirrorInstance.focus()\** — Gives the editor focus and places a blinking cursor at the beginning of the document. Since \ eloadCodeMirror()\ (used by toggle line numbers / tab size settings) calls \loadCodeMirror()\ internally, the fix applies to both initial file loading and editor setting changes. ### Testing 1. Go to any Edit Gradeable page 2. Click the **Submission/Autograding** tab 3. Select an uploaded autograding configuration 4. Click **Open Editor** 5. Click on \config.json\ (or any file) in the file tree 6. ✅ A blinking cursor appears at the beginning of the document 7. Click within the text → cursor moves to clicked position 8. Toggle line numbers / tab size → cursor remains visible after reload 9. Switch between files → cursor appears for each newly loaded file Closes Submitty#12551 Co-authored-by: Emma Roy <[email protected]>
…2554) ## Description Fixes the missing blinking cursor in the autograding configuration editor on the Edit Gradeable > Submission/Autograding tab. When a file (e.g., \config.json\) is clicked in the file tree to open it in the CodeMirror editor, no cursor is visible. The user can type and edit, but there is no visual indicator of the cursor position, making editing difficult and confusing. ### Root Cause The CodeMirror instance is created inside a container (\#gradeable-config-structure\) that starts with \display: none\ and is toggled open dynamically. When \CodeMirror.fromTextArea()\ runs: 1. The editor does not automatically receive focus, so no blinking cursor is shown. 2. The editor may miscalculate its layout because it was initialized in a previously-hidden container. ### Fix Added two calls after CodeMirror initialization in \loadCodeMirror()\: - **\codeMirrorInstance.refresh()\** — Forces CodeMirror to recalculate its layout so the cursor renders at the correct position. - **\codeMirrorInstance.focus()\** — Gives the editor focus and places a blinking cursor at the beginning of the document. Since \ eloadCodeMirror()\ (used by toggle line numbers / tab size settings) calls \loadCodeMirror()\ internally, the fix applies to both initial file loading and editor setting changes. ### Testing 1. Go to any Edit Gradeable page 2. Click the **Submission/Autograding** tab 3. Select an uploaded autograding configuration 4. Click **Open Editor** 5. Click on \config.json\ (or any file) in the file tree 6. ✅ A blinking cursor appears at the beginning of the document 7. Click within the text → cursor moves to clicked position 8. Toggle line numbers / tab size → cursor remains visible after reload 9. Switch between files → cursor appears for each newly loaded file Closes Submitty#12551 Co-authored-by: Emma Roy <[email protected]>
Description
Fixes the missing blinking cursor in the autograding configuration editor on the Edit Gradeable > Submission/Autograding tab.
When a file (e.g., \config.json) is clicked in the file tree to open it in the CodeMirror editor, no cursor is visible. The user can type and edit, but there is no visual indicator of the cursor position, making editing difficult and confusing.
Root Cause
The CodeMirror instance is created inside a container (#gradeable-config-structure) that starts with \display: none\ and is toggled open dynamically. When \CodeMirror.fromTextArea()\ runs:
Fix
Added two calls after CodeMirror initialization in \loadCodeMirror():
Since
eloadCodeMirror()\ (used by toggle line numbers / tab size settings) calls \loadCodeMirror()\ internally, the fix applies to both initial file loading and editor setting changes.
Testing
Closes #12551