Data explorer editor not keeping cursor position

AI-generated summary

A bug has been reported in the Data Explorer editor where the cursor position is not remembered between content changes, and instead moves to the start of the editor. Alteras has provided a detailed report, including a video and reproducible steps. The issue appears to be caused by a recent commit, but Alteras has found that updating to the latest Discourse commit (3.4.0.beta2-dev) resolves the issue. sam has acknowledged the report and promised to sort it out over the next week.

Priority/Severity: low-medium?

Platform: Tested in Firefox. discourse data explorer plugin starting from commit d31d899 - Aug 27, 2024.

Description:
When editing in the data explorer 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 plugin is updated to latest
  2. go to data explorer 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

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

3 Likes

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

4 Likes

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)

1 Like

The initial report was tested in 3.4.0.beta1-dev ( 9d5eb6fed6 )

Updating Discourse to the latest commit 3.4.0.beta2-dev ( 7b89fdead9 ), it works properly.

4 Likes

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