Page MenuHomePhabricator

Set scrollTop to 0 in CodeMirror's AbuseFilter edit window
Closed, ResolvedPublic

Description

Since edit filters often contain a brief explanatory comment at the top of their source code, the editor should open at the top rather than at the bottom of the code.

Event Timeline

Sorry, I cannot understand this task. Could you add a reproducible link (e.g., a public abusefilter) and maybe also a screenshot with annotations?

Sorry, I cannot understand this task. Could you add a reproducible link (e.g., a public abusefilter) and maybe also a screenshot with annotations?

https://meta.wikimedia.org/wiki/Special:AbuseFilter/194

This can be reproduced when the filter code is sufficiently long. The likely cause is that the editor focuses on the end of the content when the page is loaded.

Change #1275163 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/AbuseFilter@master] ext.abuseFilter.edit.js: CodeMirror place the cursor at 0

https://gerrit.wikimedia.org/r/1275163

Bhsd changed the task status from Open to In Progress.Apr 19 2026, 6:38 AM
Bhsd claimed this task.

This can be reproduced when the filter code is sufficiently long. The likely cause is that the editor focuses on the end of the content when the page is loaded.

To clarify, the editor doesn't need to focus on the end of the code on load because we don't always append new code. Especially when the user doesn't have the abusefilter-edit permission, the filter is only viewed so the initial view should be at the top.
Also, filter editors often modify code near the top or in the middle, not necessarily at the bottom, unlike typical article editing.

Yes, you are right. The cursor at the end of the filter was an unexpected side effect when constructing the CodeMirror editor.

Change #1275163 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] ext.abuseFilter.edit.js: CodeMirror place the cursor at 0

https://gerrit.wikimedia.org/r/1275163

Dragoniez removed a project: Patch-For-Review.

@Bhsd Thank you for the patch!