JSON code interface: cursor jumps to top after paste (auto-format triggers full re-render)
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start at the Code (input-code) interface and trace the JSON parse→stringify update path described in the report. Reproduce the issue with a large JSON document and a paste in the middle, then verify that auto-formatting preserves the pasted position or approximate scroll location instead of returning to line 1, column 0.
Written by the indexing model from the issue text.
Description
Describe the Bug
Environment:
- Directus version: 12.2.0
- Database: PostgreSQL
- Hosting: Self-hosted (CoreOS / AWS EC2)
- Browser: Chrome (latest)
- Describe the bug:
When editing a JSON field using the Code (input-code) interface, pasting content causes the cursor to jump to the top of the editor (line 1, column 0). It appears that the auto-format/re-serialize behavior triggers a full reactive value replacement of the CodeMirror editor content, which resets cursor state.
This makes editing large JSON documents painful — after every paste operation, the user must manually scroll and click back to where they were working.
Additional context:
- Content versioning is disabled on the affected collection
- The jump appears to be caused by the JSON parse → stringify round-trip that Directus performs after value changes. When the stringified output differs from the raw input (e.g. different indentation), the component replaces the full editor value, which resets CodeMirror's cursor/selection state.
- A related (now resolved) issue: when content versioning was enabled, the periodic delta sync also triggered this same cursor-reset behavior during typing (after ~2s idle), and additionally injected
_user/_daterevision metadata into nested JSON objects. Disabling versioning fixed that part. - Affects usability significantly for users managing large config-style JSON payloads.
To Reproduce
- Create a collection with a JSON field using the "Code" interface
- Add a large JSON object (50+ lines)
- Place cursor somewhere in the middle of the document
- Select and paste new JSON content (or paste to replace a section)
- Observe: cursor jumps to line 1, position 0
Expected behavior:
After a paste + auto-format, the cursor should remain at the end of the pasted content (or at minimum, at the same approximate scroll position), not reset to the top of the document.
Directus Version
12.2.0
Hosting Strategy
Self-Hosted (Docker Image)
Database
PostgreSQL 18.4
- Dominant language
- TypeScript
- Stars
- 38.8k
- Forks
- 5k
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 72
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from directus/directus
-
Dragging the trigger arrow in flow.vue copies the full FlowRaw object into stagedFlow and bypasses hasEditsMay be free again A pull request for this issue was closed without being merged. OpenBug Flows Low Impact Low Reach Studio
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
directus/directus#28399 · 2 comments ·
Maintainers usually reply within 2 days
-
upstream
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
directus/directus#27190 · 3 comments ·
Maintainers usually reply within 2 days
-
Environment Sync: push/diff fails with RECORD_NOT_UNIQUE on directus_operations.resolve when a flow's operation chain is rewiredPossibly taken @psang39 claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 52/100
directus/directus#28520 · 1 comment ·
Maintainers usually reply within 2 days
-
Content Versioning: Builder (M2A) drawer shows published values instead of the version's changesPossibly taken @eldertek claimed this 3 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
directus/directus#28502 · 2 comments ·
Maintainers usually reply within 2 days
-
Concurrent session refresh creates duplicate sessions on MySQL/MariaDBPossibly taken @alexey-yarmosh claimed this 27 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
directus/directus#28492 · 1 comment ·
Maintainers usually reply within 2 days
All issues in directus/directus
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ranxianglei/billion-context#7597 ·
Maintainers usually reply within 1 day
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every runPossibly taken @kc9ddi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TeraSky-OSS/backstage-plugins#228 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
zmkfirmware/zmk#3571 ·
Maintainers usually reply within 10 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPossibly taken @lijy91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainers usually reply within 1 day