# Data explorer editor not keeping cursor position

**URL:** https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071
**Category:** Bug
**Tags:** data-explorer, fixed
**Created:** [August 30, 2024, 12:05am UTC](https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071 "2024-08-30T00:05:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [August 30, 2024, 12:05am UTC](https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071/1 "2024-08-30T00:05:50Z")

</div>

**Priority/Severity** : low-medium?

**Platform** : Tested in Firefox. discourse [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin starting from commit [d31d899 - Aug 27, 2024](https://github.com/discourse/discourse-data-explorer/commit/d31d89942ec9ad10a943ba2395e1eb13168240e4).

**Description** :  
When editing in the [data explorer](https://meta.discourse.org/t/32566?silent=true) editor, the cursor position is not remembered between each content change, and is moved to the start of the editor.

**Reproducible steps** :

1. ensure [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin is updated to latest
2. go to [data explorer](https://meta.discourse.org/t/32566?silent=true) in admin page
3. create a new query
4. attempt to change the query in the editor

**Initial Analysis** :  
This seems to be caused by the following commit, which adds an `@onChange` event hook that mutates the sql query content, causing the `@content` prop to update with new content.  
[https://github.com/discourse/discourse-data-explorer/commit/d31d89942ec9ad10a943ba2395e1eb13168240e4](https://github.com/discourse/discourse-data-explorer/commit/d31d89942ec9ad10a943ba2395e1eb13168240e4)

Rolling back to before the above commit in a dev env, the editor interacted normally.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 30, 2024, 5:21am UTC](https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071/3 "2024-08-30T05:21:06Z")

</div>

Thank you for this excellent bug report, we will get it sorted over the next week!

---

<div class="post-metadata">

### Author: ![cvx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cvx/32/152146_2.png) [@cvx](https://meta.discourse.org/u/cvx)
#### Post date: [August 30, 2024, 5:30pm UTC](https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071/4 "2024-08-30T17:30:29Z")

</div>

What’s your Discourse version? It does seem to work correctly with the latest core commit, and should work with any tagged version (incl. the latest `v3.4.0.beta1`)

---

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [August 30, 2024, 7:15pm UTC](https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071/5 "2024-08-30T19:15:13Z")

</div>

The initial report was tested in `3.4.0.beta1-dev` ( [9d5eb6fed6](https://github.com/discourse/discourse/commits/9d5eb6fed642e4aa906c8287eee02ada2612aa24) )

Updating Discourse to the latest commit `3.4.0.beta2-dev` ( [7b89fdead9](https://github.com/discourse/discourse/commits/7b89fdead98606d4f47ceb0a1d240d0f6e5f589e) ), it works properly.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [September 2, 2024, 7:15pm UTC](https://meta.discourse.org/t/data-explorer-editor-not-keeping-cursor-position/324071/6 "2024-09-02T19:15:47Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
